{"repo":"slim","file":".editorconfig","line":1,"symbol":"root","kind":"field","lang":"editorconfig","code":"root = true"} {"repo":"slim","file":".editorconfig","line":3,"symbol":"[*]\n","kind":"section","lang":"editorconfig","code":"[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\nindent_style = space\nindent_size = 4\ntrim_trailing_whitespace = true"} {"repo":"slim","file":".editorconfig","line":4,"symbol":"charset","kind":"field","lang":"editorconfig","code":"charset = utf-8"} {"repo":"slim","file":".editorconfig","line":5,"symbol":"end_of_line","kind":"field","lang":"editorconfig","code":"end_of_line = lf"} {"repo":"slim","file":".editorconfig","line":6,"symbol":"insert_final_newline","kind":"field","lang":"editorconfig","code":"insert_final_newline = true"} {"repo":"slim","file":".editorconfig","line":7,"symbol":"indent_style","kind":"field","lang":"editorconfig","code":"indent_style = space"} {"repo":"slim","file":".editorconfig","line":8,"symbol":"indent_size","kind":"field","lang":"editorconfig","code":"indent_size = 4"} {"repo":"slim","file":".editorconfig","line":9,"symbol":"trim_trailing_whitespace","kind":"field","lang":"editorconfig","code":"trim_trailing_whitespace = true"} {"repo":"slim","file":".editorconfig","line":11,"symbol":"[*.md]\n","kind":"section","lang":"editorconfig","code":"[*.md]\ntrim_trailing_whitespace = false"} {"repo":"slim","file":".editorconfig","line":12,"symbol":"trim_trailing_whitespace","kind":"field","lang":"editorconfig","code":"trim_trailing_whitespace = false"} {"repo":"slim","file":".editorconfig","line":14,"symbol":"[*.{yml,yaml}]\n","kind":"section","lang":"editorconfig","code":"[*.{yml,yaml}]\nindent_size = 2"} {"repo":"slim","file":".editorconfig","line":15,"symbol":"indent_size","kind":"field","lang":"editorconfig","code":"indent_size = 2"} {"repo":"slim","file":"Slim/App.php","line":39,"symbol":"App","kind":"class","lang":"php","doc":"@api @template TContainerInterface of (ContainerInterface|null) @template-extends RouteCollectorProxy","code":"class App extends RouteCollectorProxy implements RequestHandlerInterface\n{\n /**\n * Current version\n *\n * @var string\n */\n public const VERSION = '4.15.1';\n\n protected RouteResolverInterface $routeResolver;\n\n protected MiddlewareDispatcherInterface $middlewareDispatcher;\n\n /**\n * @param TContainerInterface $container\n */\n public function __construct(\n ResponseFactoryInterface $responseFactory,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null,\n ?RouteCollectorInterface $routeCollector = null,\n ?RouteResolverInterface $routeResolver = null,\n ?MiddlewareDispatcherInterface $middlewareDispatcher = null\n ) {\n parent::__construct(\n $responseFactory,\n $callableResolver ?? new CallableResolver($container),\n $container,\n $routeCollector\n );\n\n $this->routeResolver = $routeResolver ?? new RouteResolver($this->routeCollector);\n $routeRunner = new RouteRunner($this->routeResolver, $this->routeCollector->getRouteParser(), $this);\n\n if (!$middlewareDispatcher) {\n $middlewareDispat"} {"repo":"slim","file":"Slim/App.php","line":55,"symbol":"__construct","kind":"method","lang":"php","doc":"@param TContainerInterface $container","code":"public function __construct(\n ResponseFactoryInterface $responseFactory,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null,\n ?RouteCollectorInterface $routeCollector = null,\n ?RouteResolverInterface $routeResolver = null,\n ?MiddlewareDispatcherInterface $middlewareDispatcher = null\n ) {\n parent::__construct(\n $responseFactory,\n $callableResolver ?? new CallableResolver($container),\n $container,\n $routeCollector\n );\n\n $this->routeResolver = $routeResolver ?? new RouteResolver($this->routeCollector);\n $routeRunner = new RouteRunner($this->routeResolver, $this->routeCollector->getRouteParser(), $this);\n\n if (!$middlewareDispatcher) {\n $middlewareDispatcher = new MiddlewareDispatcher($routeRunner, $this->callableResolver, $container);\n } else {\n $middlewareDispatcher->seedMiddlewareStack($routeRunner);\n }\n\n $this->middlewareDispatcher = $middlewareDispatcher;\n }"} {"repo":"slim","file":"Slim/App.php","line":85,"symbol":"getRouteResolver","kind":"method","lang":"php","doc":"@return RouteResolverInterface","code":"public function getRouteResolver(): RouteResolverInterface\n {\n return $this->routeResolver;\n }"} {"repo":"slim","file":"Slim/App.php","line":93,"symbol":"getMiddlewareDispatcher","kind":"method","lang":"php","doc":"@return MiddlewareDispatcherInterface","code":"public function getMiddlewareDispatcher(): MiddlewareDispatcherInterface\n {\n return $this->middlewareDispatcher;\n }"} {"repo":"slim","file":"Slim/App.php","line":102,"symbol":"add","kind":"method","lang":"php","doc":"@param MiddlewareInterface|string|callable $middleware @return App","code":"public function add($middleware): self\n {\n $this->middlewareDispatcher->add($middleware);\n return $this;\n }"} {"repo":"slim","file":"Slim/App.php","line":112,"symbol":"addMiddleware","kind":"method","lang":"php","doc":"@param MiddlewareInterface $middleware @return App","code":"public function addMiddleware(MiddlewareInterface $middleware): self\n {\n $this->middlewareDispatcher->addMiddleware($middleware);\n return $this;\n }"} {"repo":"slim","file":"Slim/App.php","line":125,"symbol":"addRoutingMiddleware","kind":"method","lang":"php","doc":"Add the Slim built-in routing middleware to the app middleware stack This method can be used to control middleware order and is not required for default routing operation. @return RoutingMiddleware","code":"public function addRoutingMiddleware(): RoutingMiddleware\n {\n $routingMiddleware = new RoutingMiddleware(\n $this->getRouteResolver(),\n $this->getRouteCollector()->getRouteParser()\n );\n $this->add($routingMiddleware);\n return $routingMiddleware;\n }"} {"repo":"slim","file":"Slim/App.php","line":145,"symbol":"addErrorMiddleware","kind":"method","lang":"php","doc":"@param bool $logErrors @param bool $logErrorDetails @param LoggerInterface|null $logger @return ErrorMiddleware","code":"public function addErrorMiddleware(\n bool $displayErrorDetails,\n bool $logErrors,\n bool $logErrorDetails,\n ?LoggerInterface $logger = null\n ): ErrorMiddleware {\n $errorMiddleware = new ErrorMiddleware(\n $this->getCallableResolver(),\n $this->getResponseFactory(),\n $displayErrorDetails,\n $logErrors,\n $logErrorDetails,\n $logger\n );\n $this->add($errorMiddleware);\n return $errorMiddleware;\n }"} {"repo":"slim","file":"Slim/App.php","line":170,"symbol":"addBodyParsingMiddleware","kind":"method","lang":"php","doc":"Add the Slim body parsing middleware to the app middleware stack @param callable[] $bodyParsers @return BodyParsingMiddleware","code":"public function addBodyParsingMiddleware(array $bodyParsers = []): BodyParsingMiddleware\n {\n $bodyParsingMiddleware = new BodyParsingMiddleware($bodyParsers);\n $this->add($bodyParsingMiddleware);\n return $bodyParsingMiddleware;\n }"} {"repo":"slim","file":"Slim/App.php","line":186,"symbol":"run","kind":"method","lang":"php","doc":"This method traverses the application middleware stack and then sends the resultant Response object to the HTTP client. @param ServerRequestInterface|null $request @return void","code":"public function run(?ServerRequestInterface $request = null): void\n {\n if (!$request) {\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n $request = $serverRequestCreator->createServerRequestFromGlobals();\n }\n\n $response = $this->handle($request);\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n }"} {"repo":"slim","file":"Slim/App.php","line":207,"symbol":"handle","kind":"method","lang":"php","doc":"This method traverses the application middleware stack and then returns the resultant Response object. @param ServerRequestInterface $request @return ResponseInterface","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $response = $this->middlewareDispatcher->handle($request);\n\n /**\n * This is to be in compliance with RFC 2616, Section 9.\n * If the incoming request method is HEAD, we need to ensure that the response body\n * is empty as the request may fall back on a GET route handler due to FastRoute's\n * routing logic which could potentially append content to the response body\n * https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4\n */\n $method = strtoupper($request->getMethod());\n if ($method === 'HEAD') {\n $emptyBody = $this->responseFactory->createResponse()->getBody();\n return $response->withBody($emptyBody);\n }\n\n return $response;\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":32,"symbol":"CallableResolver","kind":"class","lang":"php","doc":"@template TContainerInterface of (ContainerInterface|null)","code":"final class CallableResolver implements AdvancedCallableResolverInterface\n{\n public static string $callablePattern = '!^([^\\:]+)\\:([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)$!';\n\n /** @var TContainerInterface $container */\n private ?ContainerInterface $container;\n\n /**\n * @param TContainerInterface $container\n */\n public function __construct(?ContainerInterface $container = null)\n {\n $this->container = $container;\n }\n\n /**\n * {@inheritdoc}\n */\n public function resolve($toResolve): callable\n {\n $toResolve = $this->prepareToResolve($toResolve);\n if (is_callable($toResolve)) {\n return $this->bindToContainer($toResolve);\n }\n $resolved = $toResolve;\n if (is_string($toResolve)) {\n $resolved = $this->resolveSlimNotation($toResolve);\n $resolved[1] ??= '__invoke';\n }\n $callable = $this->assertCallable($resolved, $toResolve);\n return $this->bindToContainer($callable);\n }\n\n /**\n * {@inheritdoc}\n */\n public function resolveRoute($toResolve): callable\n {\n return $this->resolveByPredicate($toResolve, [$this, 'isRoute'], 'handle');"} {"repo":"slim","file":"Slim/CallableResolver.php","line":42,"symbol":"__construct","kind":"method","lang":"php","doc":"@param TContainerInterface $container","code":"public function __construct(?ContainerInterface $container = null)\n {\n $this->container = $container;\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":50,"symbol":"resolve","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function resolve($toResolve): callable\n {\n $toResolve = $this->prepareToResolve($toResolve);\n if (is_callable($toResolve)) {\n return $this->bindToContainer($toResolve);\n }\n $resolved = $toResolve;\n if (is_string($toResolve)) {\n $resolved = $this->resolveSlimNotation($toResolve);\n $resolved[1] ??= '__invoke';\n }\n $callable = $this->assertCallable($resolved, $toResolve);\n return $this->bindToContainer($callable);\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":68,"symbol":"resolveRoute","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function resolveRoute($toResolve): callable\n {\n return $this->resolveByPredicate($toResolve, [$this, 'isRoute'], 'handle');\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":76,"symbol":"resolveMiddleware","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function resolveMiddleware($toResolve): callable\n {\n return $this->resolveByPredicate($toResolve, [$this, 'isMiddleware'], 'process');\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":86,"symbol":"resolveByPredicate","kind":"method","lang":"php","doc":"@param callable|array{class-string, string}|string $toResolve @throws RuntimeException","code":"private function resolveByPredicate($toResolve, callable $predicate, string $defaultMethod): callable\n {\n $toResolve = $this->prepareToResolve($toResolve);\n if (is_callable($toResolve)) {\n return $this->bindToContainer($toResolve);\n }\n $resolved = $toResolve;\n if ($predicate($toResolve)) {\n $resolved = [$toResolve, $defaultMethod];\n }\n if (is_string($toResolve)) {\n [$instance, $method] = $this->resolveSlimNotation($toResolve);\n if ($method === null && $predicate($instance)) {\n $method = $defaultMethod;\n }\n $resolved = [$instance, $method ?? '__invoke'];\n }\n $callable = $this->assertCallable($resolved, $toResolve);\n return $this->bindToContainer($callable);\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":110,"symbol":"isRoute","kind":"method","lang":"php","doc":"@param mixed $toResolve","code":"private function isRoute($toResolve): bool\n {\n return $toResolve instanceof RequestHandlerInterface;\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":118,"symbol":"isMiddleware","kind":"method","lang":"php","doc":"@param mixed $toResolve","code":"private function isMiddleware($toResolve): bool\n {\n return $toResolve instanceof MiddlewareInterface;\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":128,"symbol":"resolveSlimNotation","kind":"method","lang":"php","doc":"@throws RuntimeException @return array{object, string|null} [Instance, Method Name]","code":"private function resolveSlimNotation(string $toResolve): array\n {\n /** @psalm-suppress ArgumentTypeCoercion */\n preg_match(CallableResolver::$callablePattern, $toResolve, $matches);\n [$class, $method] = $matches ? [$matches[1], $matches[2]] : [$toResolve, null];\n\n if ($this->container && $this->container->has($class)) {\n $instance = $this->container->get($class);\n if (!is_object($instance)) {\n throw new RuntimeException(sprintf('%s container entry is not an object', $class));\n }\n } else {\n if (!class_exists($class)) {\n if ($method) {\n $class .= '::' . $method . '()';\n }\n throw new RuntimeException(sprintf('Callable %s does not exist', $class));\n }\n $instance = new $class($this->container);\n }\n return [$instance, $method];\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":157,"symbol":"assertCallable","kind":"method","lang":"php","doc":"@param mixed $resolved @param mixed $toResolve @throws RuntimeException","code":"private function assertCallable($resolved, $toResolve): callable\n {\n if (!is_callable($resolved)) {\n if (is_callable($toResolve) || is_object($toResolve) || is_array($toResolve)) {\n $formatedToResolve = ($toResolveJson = json_encode($toResolve)) !== false ? $toResolveJson : '';\n } else {\n $formatedToResolve = is_string($toResolve) ? $toResolve : '';\n }\n throw new RuntimeException(sprintf('%s is not resolvable', $formatedToResolve));\n }\n return $resolved;\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":170,"symbol":"bindToContainer","kind":"method","lang":"php","code":"private function bindToContainer(callable $callable): callable\n {\n if (is_array($callable) && $callable[0] instanceof Closure) {\n $callable = $callable[0];\n }\n if ($this->container && $callable instanceof Closure) {\n /** @var Closure $callable */\n $callable = $callable->bindTo($this->container);\n }\n return $callable;\n }"} {"repo":"slim","file":"Slim/CallableResolver.php","line":187,"symbol":"prepareToResolve","kind":"method","lang":"php","doc":"@param callable|string|array{class-string, string}|mixed $toResolve @return callable|string|array{class-string, string}|mixed","code":"private function prepareToResolve($toResolve)\n {\n if (!is_array($toResolve)) {\n return $toResolve;\n }\n $candidate = $toResolve;\n $class = array_shift($candidate);\n $method = array_shift($candidate);\n if (is_string($class) && is_string($method)) {\n return $class . ':' . $method;\n }\n return $toResolve;\n }"} {"repo":"slim","file":"Slim/Error/AbstractErrorRenderer.php","line":23,"symbol":"AbstractErrorRenderer","kind":"class","lang":"php","doc":"Abstract Slim application error renderer It outputs the error message and diagnostic information in one of the following formats: JSON, XML, Plain Text or HTML","code":"abstract class AbstractErrorRenderer implements ErrorRendererInterface\n{\n protected string $defaultErrorTitle = 'Slim Application Error';\n\n protected string $defaultErrorDescription = 'A website error has occurred. Sorry for the temporary inconvenience.';\n\n protected function getErrorTitle(Throwable $exception): string\n {\n if ($exception instanceof HttpException) {\n return $exception->getTitle();\n }\n\n return $this->defaultErrorTitle;\n }\n\n protected function getErrorDescription(Throwable $exception): string\n {\n if ($exception instanceof HttpException) {\n return $exception->getDescription();\n }\n\n return $this->defaultErrorDescription;\n }\n}"} {"repo":"slim","file":"Slim/Error/AbstractErrorRenderer.php","line":29,"symbol":"getErrorTitle","kind":"method","lang":"php","code":"protected function getErrorTitle(Throwable $exception): string\n {\n if ($exception instanceof HttpException) {\n return $exception->getTitle();\n }\n\n return $this->defaultErrorTitle;\n }"} {"repo":"slim","file":"Slim/Error/AbstractErrorRenderer.php","line":38,"symbol":"getErrorDescription","kind":"method","lang":"php","code":"protected function getErrorDescription(Throwable $exception): string\n {\n if ($exception instanceof HttpException) {\n return $exception->getDescription();\n }\n\n return $this->defaultErrorDescription;\n }"} {"repo":"slim","file":"Slim/Error/Renderers/HtmlErrorRenderer.php","line":27,"symbol":"HtmlErrorRenderer","kind":"class","lang":"php","doc":"Default Slim application HTML Error Renderer","code":"class HtmlErrorRenderer extends AbstractErrorRenderer\n{\n public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n if ($displayErrorDetails) {\n $html = '

The application could not run because of the following error:

';\n $html .= '

Details

';\n $html .= $this->renderExceptionFragment($exception);\n } else {\n $description = htmlspecialchars(\n $this->getErrorDescription($exception),\n ENT_QUOTES | ENT_SUBSTITUTE,\n 'UTF-8'\n );\n $html = \"

{$description}

\";\n }\n\n return $this->renderHtmlBody($this->getErrorTitle($exception), $html);\n }\n\n private function renderExceptionFragment(Throwable $exception): string\n {\n $html = sprintf('
Type: %s
', get_class($exception));\n\n $code = $exception->getCode();\n $html .= sprintf('
Code: %s
', $code);\n\n $html .= sprintf('
Message: %s
', htmlentities($exception->getMessage()));\n\n $html .= sprintf('
File: %s
', $exception->getF"} {"repo":"slim","file":"Slim/Error/Renderers/HtmlErrorRenderer.php","line":29,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n if ($displayErrorDetails) {\n $html = '

The application could not run because of the following error:

';\n $html .= '

Details

';\n $html .= $this->renderExceptionFragment($exception);\n } else {\n $description = htmlspecialchars(\n $this->getErrorDescription($exception),\n ENT_QUOTES | ENT_SUBSTITUTE,\n 'UTF-8'\n );\n $html = \"

{$description}

\";\n }\n\n return $this->renderHtmlBody($this->getErrorTitle($exception), $html);\n }"} {"repo":"slim","file":"Slim/Error/Renderers/HtmlErrorRenderer.php","line":47,"symbol":"renderExceptionFragment","kind":"method","lang":"php","code":"private function renderExceptionFragment(Throwable $exception): string\n {\n $html = sprintf('
Type: %s
', get_class($exception));\n\n $code = $exception->getCode();\n $html .= sprintf('
Code: %s
', $code);\n\n $html .= sprintf('
Message: %s
', htmlentities($exception->getMessage()));\n\n $html .= sprintf('
File: %s
', $exception->getFile());\n\n $html .= sprintf('
Line: %s
', $exception->getLine());\n\n $html .= '

Trace

';\n $html .= sprintf('
%s
', htmlentities($exception->getTraceAsString()));\n\n return $html;\n }"} {"repo":"slim","file":"Slim/Error/Renderers/HtmlErrorRenderer.php","line":66,"symbol":"renderHtmlBody","kind":"method","lang":"php","code":"public function renderHtmlBody(string $title = '', string $html = ''): string\n {\n $title = htmlspecialchars($title, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');\n\n return sprintf(\n '' .\n '' .\n ' ' .\n ' ' .\n ' ' .\n ' %s' .\n ' ' .\n ' ' .\n ' ' .\n '

%s

' .\n '
%s
' .\n ' Go Back' .\n ' ' .\n '',\n $title,\n $title,\n $html\n );\n }"} {"repo":"slim","file":"Slim/Error/Renderers/JsonErrorRenderer.php","line":26,"symbol":"JsonErrorRenderer","kind":"class","lang":"php","doc":"Default Slim application JSON Error Renderer","code":"class JsonErrorRenderer extends AbstractErrorRenderer\n{\n public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n $error = ['message' => $this->getErrorTitle($exception)];\n\n if ($displayErrorDetails) {\n $error['exception'] = [];\n do {\n $error['exception'][] = $this->formatExceptionFragment($exception);\n } while ($exception = $exception->getPrevious());\n }\n\n return (string) json_encode(\n $error,\n JSON_INVALID_UTF8_SUBSTITUTE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES\n );\n }\n\n /**\n * @return array\n */\n private function formatExceptionFragment(Throwable $exception): array\n {\n $code = $exception->getCode();\n return [\n 'type' => get_class($exception),\n 'code' => $code,\n 'message' => $exception->getMessage(),\n 'file' => $exception->getFile(),\n 'line' => $exception->getLine(),\n ];\n }\n}"} {"repo":"slim","file":"Slim/Error/Renderers/JsonErrorRenderer.php","line":28,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n $error = ['message' => $this->getErrorTitle($exception)];\n\n if ($displayErrorDetails) {\n $error['exception'] = [];\n do {\n $error['exception'][] = $this->formatExceptionFragment($exception);\n } while ($exception = $exception->getPrevious());\n }\n\n return (string) json_encode(\n $error,\n JSON_INVALID_UTF8_SUBSTITUTE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES\n );\n }"} {"repo":"slim","file":"Slim/Error/Renderers/JsonErrorRenderer.php","line":48,"symbol":"formatExceptionFragment","kind":"method","lang":"php","doc":"@return array","code":"private function formatExceptionFragment(Throwable $exception): array\n {\n $code = $exception->getCode();\n return [\n 'type' => get_class($exception),\n 'code' => $code,\n 'message' => $exception->getMessage(),\n 'file' => $exception->getFile(),\n 'line' => $exception->getLine(),\n ];\n }"} {"repo":"slim","file":"Slim/Error/Renderers/PlainTextErrorRenderer.php","line":23,"symbol":"PlainTextErrorRenderer","kind":"class","lang":"php","doc":"Default Slim application Plain Text Error Renderer","code":"class PlainTextErrorRenderer extends AbstractErrorRenderer\n{\n public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n $text = \"{$this->getErrorTitle($exception)}\\n\";\n\n if ($displayErrorDetails) {\n $text .= $this->formatExceptionFragment($exception);\n\n while ($exception = $exception->getPrevious()) {\n $text .= \"\\nPrevious Error:\\n\";\n $text .= $this->formatExceptionFragment($exception);\n }\n }\n\n return $text;\n }\n\n private function formatExceptionFragment(Throwable $exception): string\n {\n $text = sprintf(\"Type: %s\\n\", get_class($exception));\n\n $code = $exception->getCode();\n\n $text .= sprintf(\"Code: %s\\n\", $code);\n\n $text .= sprintf(\"Message: %s\\n\", $exception->getMessage());\n\n $text .= sprintf(\"File: %s\\n\", $exception->getFile());\n\n $text .= sprintf(\"Line: %s\\n\", $exception->getLine());\n\n $text .= sprintf('Trace: %s', $exception->getTraceAsString());\n\n return $text;\n }\n}"} {"repo":"slim","file":"Slim/Error/Renderers/PlainTextErrorRenderer.php","line":25,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n $text = \"{$this->getErrorTitle($exception)}\\n\";\n\n if ($displayErrorDetails) {\n $text .= $this->formatExceptionFragment($exception);\n\n while ($exception = $exception->getPrevious()) {\n $text .= \"\\nPrevious Error:\\n\";\n $text .= $this->formatExceptionFragment($exception);\n }\n }\n\n return $text;\n }"} {"repo":"slim","file":"Slim/Error/Renderers/PlainTextErrorRenderer.php","line":41,"symbol":"formatExceptionFragment","kind":"method","lang":"php","code":"private function formatExceptionFragment(Throwable $exception): string\n {\n $text = sprintf(\"Type: %s\\n\", get_class($exception));\n\n $code = $exception->getCode();\n\n $text .= sprintf(\"Code: %s\\n\", $code);\n\n $text .= sprintf(\"Message: %s\\n\", $exception->getMessage());\n\n $text .= sprintf(\"File: %s\\n\", $exception->getFile());\n\n $text .= sprintf(\"Line: %s\\n\", $exception->getLine());\n\n $text .= sprintf('Trace: %s', $exception->getTraceAsString());\n\n return $text;\n }"} {"repo":"slim","file":"Slim/Error/Renderers/XmlErrorRenderer.php","line":23,"symbol":"XmlErrorRenderer","kind":"class","lang":"php","doc":"Default Slim application XML Error Renderer","code":"class XmlErrorRenderer extends AbstractErrorRenderer\n{\n public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n $xml = '<' . '?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?' . \">\\n\";\n $xml .= \"\\n \" . $this->createCdataSection($this->getErrorTitle($exception)) . \"\\n\";\n\n if ($displayErrorDetails) {\n do {\n $xml .= \" \\n\";\n $xml .= ' ' . get_class($exception) . \"\\n\";\n $xml .= ' ' . $exception->getCode() . \"\\n\";\n $xml .= ' ' . $this->createCdataSection($exception->getMessage()) . \"\\n\";\n $xml .= ' ' . $exception->getFile() . \"\\n\";\n $xml .= ' ' . $exception->getLine() . \"\\n\";\n $xml .= \" \\n\";\n } while ($exception = $exception->getPrevious());\n }\n\n $xml .= '';\n\n return $xml;\n }\n\n /**\n * Returns a CDATA section with the given content.\n */\n private function createCdataSection(string $content): string\n {\n return spri"} {"repo":"slim","file":"Slim/Error/Renderers/XmlErrorRenderer.php","line":25,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(Throwable $exception, bool $displayErrorDetails): string\n {\n $xml = '<' . '?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?' . \">\\n\";\n $xml .= \"\\n \" . $this->createCdataSection($this->getErrorTitle($exception)) . \"\\n\";\n\n if ($displayErrorDetails) {\n do {\n $xml .= \" \\n\";\n $xml .= ' ' . get_class($exception) . \"\\n\";\n $xml .= ' ' . $exception->getCode() . \"\\n\";\n $xml .= ' ' . $this->createCdataSection($exception->getMessage()) . \"\\n\";\n $xml .= ' ' . $exception->getFile() . \"\\n\";\n $xml .= ' ' . $exception->getLine() . \"\\n\";\n $xml .= \" \\n\";\n } while ($exception = $exception->getPrevious());\n }\n\n $xml .= '';\n\n return $xml;\n }"} {"repo":"slim","file":"Slim/Error/Renderers/XmlErrorRenderer.php","line":50,"symbol":"createCdataSection","kind":"method","lang":"php","doc":"Returns a CDATA section with the given content.","code":"private function createCdataSection(string $content): string\n {\n return sprintf('', str_replace(']]>', ']]]]>', $content));\n }"} {"repo":"slim","file":"Slim/Exception/HttpBadRequestException.php","line":14,"symbol":"HttpBadRequestException","kind":"class","lang":"php","doc":"@api","code":"class HttpBadRequestException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 400;\n\n /**\n * @var string\n */\n protected $message = 'Bad request.';\n\n protected string $title = '400 Bad Request';\n protected string $description = 'The server cannot or will not process ' .\n 'the request due to an apparent client error.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":21,"symbol":"HttpException","kind":"class","lang":"php","doc":"@api @method int getCode()","code":"class HttpException extends RuntimeException\n{\n protected ServerRequestInterface $request;\n\n protected string $title = '';\n\n protected string $description = '';\n\n public function __construct(\n ServerRequestInterface $request,\n string $message = '',\n int $code = 0,\n ?Throwable $previous = null\n ) {\n parent::__construct($message, $code, $previous);\n $this->request = $request;\n }\n\n public function getRequest(): ServerRequestInterface\n {\n return $this->request;\n }\n\n public function getTitle(): string\n {\n return $this->title;\n }\n\n public function setTitle(string $title): self\n {\n $this->title = $title;\n return $this;\n }\n\n public function getDescription(): string\n {\n return $this->description;\n }\n\n public function setDescription(string $description): self\n {\n $this->description = $description;\n return $this;\n }\n}"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":29,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(\n ServerRequestInterface $request,\n string $message = '',\n int $code = 0,\n ?Throwable $previous = null\n ) {\n parent::__construct($message, $code, $previous);\n $this->request = $request;\n }"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":39,"symbol":"getRequest","kind":"method","lang":"php","code":"public function getRequest(): ServerRequestInterface\n {\n return $this->request;\n }"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":44,"symbol":"getTitle","kind":"method","lang":"php","code":"public function getTitle(): string\n {\n return $this->title;\n }"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":49,"symbol":"setTitle","kind":"method","lang":"php","code":"public function setTitle(string $title): self\n {\n $this->title = $title;\n return $this;\n }"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":55,"symbol":"getDescription","kind":"method","lang":"php","code":"public function getDescription(): string\n {\n return $this->description;\n }"} {"repo":"slim","file":"Slim/Exception/HttpException.php","line":60,"symbol":"setDescription","kind":"method","lang":"php","code":"public function setDescription(string $description): self\n {\n $this->description = $description;\n return $this;\n }"} {"repo":"slim","file":"Slim/Exception/HttpForbiddenException.php","line":14,"symbol":"HttpForbiddenException","kind":"class","lang":"php","doc":"@api","code":"class HttpForbiddenException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 403;\n\n /**\n * @var string\n */\n protected $message = 'Forbidden.';\n\n protected string $title = '403 Forbidden';\n protected string $description = 'You are not permitted to perform the requested operation.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpGoneException.php","line":14,"symbol":"HttpGoneException","kind":"class","lang":"php","doc":"@api","code":"class HttpGoneException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 410;\n\n /**\n * @var string\n */\n protected $message = 'Gone.';\n\n protected string $title = '410 Gone';\n protected string $description = 'The target resource is no longer available at the origin server.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpInternalServerErrorException.php","line":14,"symbol":"HttpInternalServerErrorException","kind":"class","lang":"php","doc":"@api","code":"class HttpInternalServerErrorException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 500;\n\n /**\n * @var string\n */\n protected $message = 'Internal server error.';\n\n protected string $title = '500 Internal Server Error';\n protected string $description = 'Unexpected condition encountered preventing server from fulfilling request.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpMethodNotAllowedException.php","line":15,"symbol":"HttpMethodNotAllowedException","kind":"class","lang":"php","code":"class HttpMethodNotAllowedException extends HttpSpecializedException\n{\n /**\n * @var string[]\n */\n protected array $allowedMethods = [];\n\n /**\n * @var int\n */\n protected $code = 405;\n\n /**\n * @var string\n */\n protected $message = 'Method not allowed.';\n\n protected string $title = '405 Method Not Allowed';\n protected string $description = 'The request method is not supported for the requested resource.';\n\n /**\n * @return string[]\n */\n public function getAllowedMethods(): array\n {\n return $this->allowedMethods;\n }\n\n /**\n * @param string[] $methods\n */\n public function setAllowedMethods(array $methods): self\n {\n $this->allowedMethods = $methods;\n $this->message = 'Method not allowed. Must be one of: ' . implode(', ', $methods);\n return $this;\n }\n}"} {"repo":"slim","file":"Slim/Exception/HttpMethodNotAllowedException.php","line":38,"symbol":"getAllowedMethods","kind":"method","lang":"php","doc":"@return string[]","code":"public function getAllowedMethods(): array\n {\n return $this->allowedMethods;\n }"} {"repo":"slim","file":"Slim/Exception/HttpMethodNotAllowedException.php","line":46,"symbol":"setAllowedMethods","kind":"method","lang":"php","doc":"@param string[] $methods","code":"public function setAllowedMethods(array $methods): self\n {\n $this->allowedMethods = $methods;\n $this->message = 'Method not allowed. Must be one of: ' . implode(', ', $methods);\n return $this;\n }"} {"repo":"slim","file":"Slim/Exception/HttpNotFoundException.php","line":13,"symbol":"HttpNotFoundException","kind":"class","lang":"php","code":"class HttpNotFoundException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 404;\n\n /**\n * @var string\n */\n protected $message = 'Not found.';\n\n protected string $title = '404 Not Found';\n protected string $description = 'The requested resource could not be found. Please verify the URI and try again.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpNotImplementedException.php","line":14,"symbol":"HttpNotImplementedException","kind":"class","lang":"php","doc":"@api","code":"class HttpNotImplementedException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 501;\n\n /**\n * @var string\n */\n protected $message = 'Not implemented.';\n\n protected string $title = '501 Not Implemented';\n protected string $description = 'The server does not support the functionality required to fulfill the request.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpSpecializedException.php","line":16,"symbol":"HttpSpecializedException","kind":"class","lang":"php","code":"abstract class HttpSpecializedException extends HttpException\n{\n /**\n * @param ServerRequestInterface $request\n * @param string|null $message\n * @param Throwable|null $previous\n */\n public function __construct(ServerRequestInterface $request, ?string $message = null, ?Throwable $previous = null)\n {\n if ($message !== null) {\n $this->message = $message;\n }\n\n // @phpstan-ignore-next-line\n parent::__construct($request, $this->message, $this->code, $previous);\n }\n}"} {"repo":"slim","file":"Slim/Exception/HttpSpecializedException.php","line":23,"symbol":"__construct","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request @param string|null $message @param Throwable|null $previous","code":"public function __construct(ServerRequestInterface $request, ?string $message = null, ?Throwable $previous = null)\n {\n if ($message !== null) {\n $this->message = $message;\n }\n\n // @phpstan-ignore-next-line\n parent::__construct($request, $this->message, $this->code, $previous);\n }"} {"repo":"slim","file":"Slim/Exception/HttpTooManyRequestsException.php","line":14,"symbol":"HttpTooManyRequestsException","kind":"class","lang":"php","doc":"@api","code":"class HttpTooManyRequestsException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 429;\n\n /**\n * @var string\n */\n protected $message = 'Too many requests.';\n\n protected string $title = '429 Too Many Requests';\n protected string $description = 'The client application has surpassed its rate limit, ' .\n 'or number of requests they can send in a given period of time.';\n}"} {"repo":"slim","file":"Slim/Exception/HttpUnauthorizedException.php","line":14,"symbol":"HttpUnauthorizedException","kind":"class","lang":"php","doc":"@api","code":"class HttpUnauthorizedException extends HttpSpecializedException\n{\n /**\n * @var int\n */\n protected $code = 401;\n\n /**\n * @var string\n */\n protected $message = 'Unauthorized.';\n\n protected string $title = '401 Unauthorized';\n protected string $description = 'The request requires valid user authentication.';\n}"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":28,"symbol":"AppFactory","kind":"class","lang":"php","doc":"@api","code":"class AppFactory\n{\n protected static ?Psr17FactoryProviderInterface $psr17FactoryProvider = null;\n\n protected static ?ResponseFactoryInterface $responseFactory = null;\n\n protected static ?StreamFactoryInterface $streamFactory = null;\n\n protected static ?ContainerInterface $container = null;\n\n protected static ?CallableResolverInterface $callableResolver = null;\n\n protected static ?RouteCollectorInterface $routeCollector = null;\n\n protected static ?RouteResolverInterface $routeResolver = null;\n\n protected static ?MiddlewareDispatcherInterface $middlewareDispatcher = null;\n\n protected static bool $slimHttpDecoratorsAutomaticDetectionEnabled = true;\n\n /**\n * @template TContainerInterface of (ContainerInterface|null)\n * @param TContainerInterface $container\n * @return (TContainerInterface is ContainerInterface ? App : App)\n */\n public static function create(\n ?ResponseFactoryInterface $responseFactory = null,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null,\n ?RouteCollectorInterface $routeCollector = null,\n ?Route"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":53,"symbol":"create","kind":"method","lang":"php","doc":"@template TContainerInterface of (ContainerInterface|null) @param TContainerInterface $container @return (TContainerInterface is ContainerInterface ? App : App)","code":"public static function create(\n ?ResponseFactoryInterface $responseFactory = null,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null,\n ?RouteCollectorInterface $routeCollector = null,\n ?RouteResolverInterface $routeResolver = null,\n ?MiddlewareDispatcherInterface $middlewareDispatcher = null\n ): App {\n static::$responseFactory = $responseFactory ?? static::$responseFactory;\n return new App(\n self::determineResponseFactory(),\n $container ?? static::$container,\n $callableResolver ?? static::$callableResolver,\n $routeCollector ?? static::$routeCollector,\n $routeResolver ?? static::$routeResolver,\n $middlewareDispatcher ?? static::$middlewareDispatcher\n );\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":77,"symbol":"createFromContainer","kind":"method","lang":"php","doc":"@template TContainerInterface of (ContainerInterface) @param TContainerInterface $container @return App","code":"public static function createFromContainer(ContainerInterface $container): App\n {\n $responseFactory = $container->has(ResponseFactoryInterface::class)\n && (\n $responseFactoryFromContainer = $container->get(ResponseFactoryInterface::class)\n ) instanceof ResponseFactoryInterface\n ? $responseFactoryFromContainer\n : self::determineResponseFactory();\n\n $callableResolver = $container->has(CallableResolverInterface::class)\n && (\n $callableResolverFromContainer = $container->get(CallableResolverInterface::class)\n ) instanceof CallableResolverInterface\n ? $callableResolverFromContainer\n : null;\n\n $routeCollector = $container->has(RouteCollectorInterface::class)\n && (\n $routeCollectorFromContainer = $container->get(RouteCollectorInterface::class)\n ) instanceof RouteCollectorInterface\n ? $routeCollectorFromContainer\n : null;\n\n $routeResolver = $container->has(RouteResolverInterface::class)\n && (\n $routeResolverFromContainer = $container->get(RouteResolverInterface::class)\n ) instanceof RouteResolver"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":127,"symbol":"determineResponseFactory","kind":"method","lang":"php","doc":"@throws RuntimeException","code":"public static function determineResponseFactory(): ResponseFactoryInterface\n {\n if (static::$responseFactory) {\n if (static::$streamFactory) {\n return static::attemptResponseFactoryDecoration(static::$responseFactory, static::$streamFactory);\n }\n return static::$responseFactory;\n }\n\n $psr17FactoryProvider = static::$psr17FactoryProvider ?? new Psr17FactoryProvider();\n\n /** @var Psr17Factory $psr17factory */\n foreach ($psr17FactoryProvider->getFactories() as $psr17factory) {\n if ($psr17factory::isResponseFactoryAvailable()) {\n $responseFactory = $psr17factory::getResponseFactory();\n\n if (static::$streamFactory || $psr17factory::isStreamFactoryAvailable()) {\n $streamFactory = static::$streamFactory ?? $psr17factory::getStreamFactory();\n return static::attemptResponseFactoryDecoration($responseFactory, $streamFactory);\n }\n\n return $responseFactory;\n }\n }\n\n throw new RuntimeException(\n \"Could not detect any PSR-17 ResponseFactory implementations. \" .\n "} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":159,"symbol":"attemptResponseFactoryDecoration","kind":"method","lang":"php","code":"protected static function attemptResponseFactoryDecoration(\n ResponseFactoryInterface $responseFactory,\n StreamFactoryInterface $streamFactory\n ): ResponseFactoryInterface {\n if (\n static::$slimHttpDecoratorsAutomaticDetectionEnabled\n && SlimHttpPsr17Factory::isResponseFactoryAvailable()\n ) {\n return SlimHttpPsr17Factory::createDecoratedResponseFactory($responseFactory, $streamFactory);\n }\n\n return $responseFactory;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":173,"symbol":"setPsr17FactoryProvider","kind":"method","lang":"php","code":"public static function setPsr17FactoryProvider(Psr17FactoryProviderInterface $psr17FactoryProvider): void\n {\n static::$psr17FactoryProvider = $psr17FactoryProvider;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":178,"symbol":"setResponseFactory","kind":"method","lang":"php","code":"public static function setResponseFactory(ResponseFactoryInterface $responseFactory): void\n {\n static::$responseFactory = $responseFactory;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":183,"symbol":"setStreamFactory","kind":"method","lang":"php","code":"public static function setStreamFactory(StreamFactoryInterface $streamFactory): void\n {\n static::$streamFactory = $streamFactory;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":188,"symbol":"setContainer","kind":"method","lang":"php","code":"public static function setContainer(ContainerInterface $container): void\n {\n static::$container = $container;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":193,"symbol":"setCallableResolver","kind":"method","lang":"php","code":"public static function setCallableResolver(CallableResolverInterface $callableResolver): void\n {\n static::$callableResolver = $callableResolver;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":198,"symbol":"setRouteCollector","kind":"method","lang":"php","code":"public static function setRouteCollector(RouteCollectorInterface $routeCollector): void\n {\n static::$routeCollector = $routeCollector;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":203,"symbol":"setRouteResolver","kind":"method","lang":"php","code":"public static function setRouteResolver(RouteResolverInterface $routeResolver): void\n {\n static::$routeResolver = $routeResolver;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":208,"symbol":"setMiddlewareDispatcher","kind":"method","lang":"php","code":"public static function setMiddlewareDispatcher(MiddlewareDispatcherInterface $middlewareDispatcher): void\n {\n static::$middlewareDispatcher = $middlewareDispatcher;\n }"} {"repo":"slim","file":"Slim/Factory/AppFactory.php","line":213,"symbol":"setSlimHttpDecoratorsAutomaticDetection","kind":"method","lang":"php","code":"public static function setSlimHttpDecoratorsAutomaticDetection(bool $enabled): void\n {\n static::$slimHttpDecoratorsAutomaticDetectionEnabled = $enabled;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/GuzzlePsr17Factory.php","line":13,"symbol":"GuzzlePsr17Factory","kind":"class","lang":"php","code":"class GuzzlePsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'GuzzleHttp\\Psr7\\HttpFactory';\n protected static string $streamFactoryClass = 'GuzzleHttp\\Psr7\\HttpFactory';\n protected static string $serverRequestCreatorClass = 'GuzzleHttp\\Psr7\\ServerRequest';\n protected static string $serverRequestCreatorMethod = 'fromGlobals';\n}"} {"repo":"slim","file":"Slim/Factory/Psr17/HttpSoftPsr17Factory.php","line":13,"symbol":"HttpSoftPsr17Factory","kind":"class","lang":"php","code":"class HttpSoftPsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'HttpSoft\\Message\\ResponseFactory';\n protected static string $streamFactoryClass = 'HttpSoft\\Message\\StreamFactory';\n protected static string $serverRequestCreatorClass = 'HttpSoft\\ServerRequest\\ServerRequestCreator';\n protected static string $serverRequestCreatorMethod = 'createFromGlobals';\n}"} {"repo":"slim","file":"Slim/Factory/Psr17/LaminasDiactorosPsr17Factory.php","line":13,"symbol":"LaminasDiactorosPsr17Factory","kind":"class","lang":"php","code":"class LaminasDiactorosPsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'Laminas\\Diactoros\\ResponseFactory';\n protected static string $streamFactoryClass = 'Laminas\\Diactoros\\StreamFactory';\n protected static string $serverRequestCreatorClass = 'Laminas\\Diactoros\\ServerRequestFactory';\n protected static string $serverRequestCreatorMethod = 'fromGlobals';\n}"} {"repo":"slim","file":"Slim/Factory/Psr17/NyholmPsr17Factory.php","line":9,"symbol":"NyholmPsr17Factory","kind":"class","lang":"php","code":"class NyholmPsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'Nyholm\\Psr7\\Factory\\Psr17Factory';\n protected static string $streamFactoryClass = 'Nyholm\\Psr7\\Factory\\Psr17Factory';\n protected static string $serverRequestCreatorClass = 'Nyholm\\Psr7Server\\ServerRequestCreator';\n protected static string $serverRequestCreatorMethod = 'fromGlobals';\n\n /**\n * {@inheritdoc}\n */\n public static function getServerRequestCreator(): ServerRequestCreatorInterface\n {\n /*\n * Nyholm Psr17Factory implements all factories in one unified\n * factory which implements all of the PSR-17 factory interfaces\n */\n $psr17Factory = new static::$responseFactoryClass();\n\n $serverRequestCreator = new static::$serverRequestCreatorClass(\n $psr17Factory,\n $psr17Factory,\n $psr17Factory,\n $psr17Factory\n );\n\n return new ServerRequestCreator($serverRequestCreator, static::$serverRequestCreatorMethod);\n }\n\n /**\n * {@inheritdoc}\n */\n public static function isServerRequestCreatorAvailable(): bool\n {\n return (\n parent::isS"} {"repo":"slim","file":"Slim/Factory/Psr17/NyholmPsr17Factory.php","line":19,"symbol":"getServerRequestCreator","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function getServerRequestCreator(): ServerRequestCreatorInterface\n {\n /*\n * Nyholm Psr17Factory implements all factories in one unified\n * factory which implements all of the PSR-17 factory interfaces\n */\n $psr17Factory = new static::$responseFactoryClass();\n\n $serverRequestCreator = new static::$serverRequestCreatorClass(\n $psr17Factory,\n $psr17Factory,\n $psr17Factory,\n $psr17Factory\n );\n\n return new ServerRequestCreator($serverRequestCreator, static::$serverRequestCreatorMethod);\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/NyholmPsr17Factory.php","line":40,"symbol":"isServerRequestCreatorAvailable","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function isServerRequestCreatorAvailable(): bool\n {\n return (\n parent::isServerRequestCreatorAvailable()\n && class_exists(static::$responseFactoryClass)\n );\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":22,"symbol":"Psr17Factory","kind":"class","lang":"php","code":"abstract class Psr17Factory implements Psr17FactoryInterface\n{\n protected static string $responseFactoryClass;\n\n protected static string $streamFactoryClass;\n\n protected static string $serverRequestCreatorClass;\n\n protected static string $serverRequestCreatorMethod;\n\n /**\n * {@inheritdoc}\n */\n public static function getResponseFactory(): ResponseFactoryInterface\n {\n if (\n !static::isResponseFactoryAvailable()\n || !(($responseFactory = new static::$responseFactoryClass()) instanceof ResponseFactoryInterface)\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a response factory.');\n }\n\n return $responseFactory;\n }\n\n /**\n * {@inheritdoc}\n */\n public static function getStreamFactory(): StreamFactoryInterface\n {\n if (\n !static::isStreamFactoryAvailable()\n || !(($streamFactory = new static::$streamFactoryClass()) instanceof StreamFactoryInterface)\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a stream factory.');\n }\n\n return $streamFactory;\n }\n\n /**\n *"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":35,"symbol":"getResponseFactory","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function getResponseFactory(): ResponseFactoryInterface\n {\n if (\n !static::isResponseFactoryAvailable()\n || !(($responseFactory = new static::$responseFactoryClass()) instanceof ResponseFactoryInterface)\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a response factory.');\n }\n\n return $responseFactory;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":50,"symbol":"getStreamFactory","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function getStreamFactory(): StreamFactoryInterface\n {\n if (\n !static::isStreamFactoryAvailable()\n || !(($streamFactory = new static::$streamFactoryClass()) instanceof StreamFactoryInterface)\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a stream factory.');\n }\n\n return $streamFactory;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":65,"symbol":"getServerRequestCreator","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function getServerRequestCreator(): ServerRequestCreatorInterface\n {\n if (!static::isServerRequestCreatorAvailable()) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a server request creator.');\n }\n\n return new ServerRequestCreator(static::$serverRequestCreatorClass, static::$serverRequestCreatorMethod);\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":77,"symbol":"isResponseFactoryAvailable","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function isResponseFactoryAvailable(): bool\n {\n return static::$responseFactoryClass && class_exists(static::$responseFactoryClass);\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":85,"symbol":"isStreamFactoryAvailable","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function isStreamFactoryAvailable(): bool\n {\n return static::$streamFactoryClass && class_exists(static::$streamFactoryClass);\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17Factory.php","line":93,"symbol":"isServerRequestCreatorAvailable","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function isServerRequestCreatorAvailable(): bool\n {\n return (\n static::$serverRequestCreatorClass\n && static::$serverRequestCreatorMethod\n && class_exists(static::$serverRequestCreatorClass)\n );\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17FactoryProvider.php","line":17,"symbol":"Psr17FactoryProvider","kind":"class","lang":"php","code":"class Psr17FactoryProvider implements Psr17FactoryProviderInterface\n{\n /**\n * @var string[]\n */\n protected static array $factories = [\n SlimPsr17Factory::class,\n HttpSoftPsr17Factory::class,\n NyholmPsr17Factory::class,\n LaminasDiactorosPsr17Factory::class,\n GuzzlePsr17Factory::class,\n ];\n\n /**\n * {@inheritdoc}\n */\n public static function getFactories(): array\n {\n return static::$factories;\n }\n\n /**\n * {@inheritdoc}\n */\n public static function setFactories(array $factories): void\n {\n static::$factories = $factories;\n }\n\n /**\n * {@inheritdoc}\n */\n public static function addFactory(string $factory): void\n {\n array_unshift(static::$factories, $factory);\n }\n}"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17FactoryProvider.php","line":33,"symbol":"getFactories","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function getFactories(): array\n {\n return static::$factories;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17FactoryProvider.php","line":41,"symbol":"setFactories","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function setFactories(array $factories): void\n {\n static::$factories = $factories;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/Psr17FactoryProvider.php","line":49,"symbol":"addFactory","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public static function addFactory(string $factory): void\n {\n array_unshift(static::$factories, $factory);\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/ServerRequestCreator.php","line":17,"symbol":"ServerRequestCreator","kind":"class","lang":"php","code":"class ServerRequestCreator implements ServerRequestCreatorInterface\n{\n /**\n * @var object|string\n */\n protected $serverRequestCreator;\n\n protected string $serverRequestCreatorMethod;\n\n /**\n * @param object|string $serverRequestCreator\n */\n public function __construct($serverRequestCreator, string $serverRequestCreatorMethod)\n {\n $this->serverRequestCreator = $serverRequestCreator;\n $this->serverRequestCreatorMethod = $serverRequestCreatorMethod;\n }\n\n /**\n * {@inheritdoc}\n */\n public function createServerRequestFromGlobals(): ServerRequestInterface\n {\n /** @var callable $callable */\n $callable = [$this->serverRequestCreator, $this->serverRequestCreatorMethod];\n\n /** @var ServerRequestInterface */\n return (Closure::fromCallable($callable))();\n }\n}"} {"repo":"slim","file":"Slim/Factory/Psr17/ServerRequestCreator.php","line":29,"symbol":"__construct","kind":"method","lang":"php","doc":"@param object|string $serverRequestCreator","code":"public function __construct($serverRequestCreator, string $serverRequestCreatorMethod)\n {\n $this->serverRequestCreator = $serverRequestCreator;\n $this->serverRequestCreatorMethod = $serverRequestCreatorMethod;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/ServerRequestCreator.php","line":38,"symbol":"createServerRequestFromGlobals","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function createServerRequestFromGlobals(): ServerRequestInterface\n {\n /** @var callable $callable */\n $callable = [$this->serverRequestCreator, $this->serverRequestCreatorMethod];\n\n /** @var ServerRequestInterface */\n return (Closure::fromCallable($callable))();\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimHttpPsr17Factory.php","line":17,"symbol":"SlimHttpPsr17Factory","kind":"class","lang":"php","code":"class SlimHttpPsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'Slim\\Http\\Factory\\DecoratedResponseFactory';\n\n /**\n * @throws RuntimeException when the factory could not be instantiated\n */\n public static function createDecoratedResponseFactory(\n ResponseFactoryInterface $responseFactory,\n StreamFactoryInterface $streamFactory\n ): ResponseFactoryInterface {\n if (\n !((\n $decoratedResponseFactory = new static::$responseFactoryClass($responseFactory, $streamFactory)\n ) instanceof ResponseFactoryInterface\n )\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a decorated response factory.');\n }\n\n return $decoratedResponseFactory;\n }\n}"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimHttpPsr17Factory.php","line":24,"symbol":"createDecoratedResponseFactory","kind":"method","lang":"php","doc":"@throws RuntimeException when the factory could not be instantiated","code":"public static function createDecoratedResponseFactory(\n ResponseFactoryInterface $responseFactory,\n StreamFactoryInterface $streamFactory\n ): ResponseFactoryInterface {\n if (\n !((\n $decoratedResponseFactory = new static::$responseFactoryClass($responseFactory, $streamFactory)\n ) instanceof ResponseFactoryInterface\n )\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a decorated response factory.');\n }\n\n return $decoratedResponseFactory;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimHttpServerRequestCreator.php","line":19,"symbol":"SlimHttpServerRequestCreator","kind":"class","lang":"php","code":"class SlimHttpServerRequestCreator implements ServerRequestCreatorInterface\n{\n protected ServerRequestCreatorInterface $serverRequestCreator;\n\n protected static string $serverRequestDecoratorClass = 'Slim\\Http\\ServerRequest';\n\n public function __construct(ServerRequestCreatorInterface $serverRequestCreator)\n {\n $this->serverRequestCreator = $serverRequestCreator;\n }\n\n /**\n * {@inheritdoc}\n */\n public function createServerRequestFromGlobals(): ServerRequestInterface\n {\n if (!static::isServerRequestDecoratorAvailable()) {\n throw new RuntimeException('The Slim-Http ServerRequest decorator is not available.');\n }\n\n $request = $this->serverRequestCreator->createServerRequestFromGlobals();\n\n if (\n !((\n $decoratedServerRequest = new static::$serverRequestDecoratorClass($request)\n ) instanceof ServerRequestInterface)\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a decorated server request.');\n }\n\n return $decoratedServerRequest;\n }\n\n public static function isServerRequestDecoratorAvailable(): bool\n {\n"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimHttpServerRequestCreator.php","line":25,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(ServerRequestCreatorInterface $serverRequestCreator)\n {\n $this->serverRequestCreator = $serverRequestCreator;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimHttpServerRequestCreator.php","line":33,"symbol":"createServerRequestFromGlobals","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function createServerRequestFromGlobals(): ServerRequestInterface\n {\n if (!static::isServerRequestDecoratorAvailable()) {\n throw new RuntimeException('The Slim-Http ServerRequest decorator is not available.');\n }\n\n $request = $this->serverRequestCreator->createServerRequestFromGlobals();\n\n if (\n !((\n $decoratedServerRequest = new static::$serverRequestDecoratorClass($request)\n ) instanceof ServerRequestInterface)\n ) {\n throw new RuntimeException(get_called_class() . ' could not instantiate a decorated server request.');\n }\n\n return $decoratedServerRequest;\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimHttpServerRequestCreator.php","line":52,"symbol":"isServerRequestDecoratorAvailable","kind":"method","lang":"php","code":"public static function isServerRequestDecoratorAvailable(): bool\n {\n return class_exists(static::$serverRequestDecoratorClass);\n }"} {"repo":"slim","file":"Slim/Factory/Psr17/SlimPsr17Factory.php","line":13,"symbol":"SlimPsr17Factory","kind":"class","lang":"php","code":"class SlimPsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'Slim\\Psr7\\Factory\\ResponseFactory';\n protected static string $streamFactoryClass = 'Slim\\Psr7\\Factory\\StreamFactory';\n protected static string $serverRequestCreatorClass = 'Slim\\Psr7\\Factory\\ServerRequestFactory';\n protected static string $serverRequestCreatorMethod = 'createFromGlobals';\n}"} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":21,"symbol":"ServerRequestCreatorFactory","kind":"class","lang":"php","doc":"@api","code":"class ServerRequestCreatorFactory\n{\n protected static ?Psr17FactoryProviderInterface $psr17FactoryProvider = null;\n\n protected static ?ServerRequestCreatorInterface $serverRequestCreator = null;\n\n protected static bool $slimHttpDecoratorsAutomaticDetectionEnabled = true;\n\n public static function create(): ServerRequestCreatorInterface\n {\n return static::determineServerRequestCreator();\n }\n\n /**\n * @throws RuntimeException\n */\n public static function determineServerRequestCreator(): ServerRequestCreatorInterface\n {\n if (static::$serverRequestCreator) {\n return static::attemptServerRequestCreatorDecoration(static::$serverRequestCreator);\n }\n\n $psr17FactoryProvider = static::$psr17FactoryProvider ?? new Psr17FactoryProvider();\n\n /** @var Psr17Factory $psr17Factory */\n foreach ($psr17FactoryProvider->getFactories() as $psr17Factory) {\n if ($psr17Factory::isServerRequestCreatorAvailable()) {\n $serverRequestCreator = $psr17Factory::getServerRequestCreator();\n return static::attemptServerRequestCreatorDecoration($serverRequestCreator);\n }\n }\n\n "} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":29,"symbol":"create","kind":"method","lang":"php","code":"public static function create(): ServerRequestCreatorInterface\n {\n return static::determineServerRequestCreator();\n }"} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":37,"symbol":"determineServerRequestCreator","kind":"method","lang":"php","doc":"@throws RuntimeException","code":"public static function determineServerRequestCreator(): ServerRequestCreatorInterface\n {\n if (static::$serverRequestCreator) {\n return static::attemptServerRequestCreatorDecoration(static::$serverRequestCreator);\n }\n\n $psr17FactoryProvider = static::$psr17FactoryProvider ?? new Psr17FactoryProvider();\n\n /** @var Psr17Factory $psr17Factory */\n foreach ($psr17FactoryProvider->getFactories() as $psr17Factory) {\n if ($psr17Factory::isServerRequestCreatorAvailable()) {\n $serverRequestCreator = $psr17Factory::getServerRequestCreator();\n return static::attemptServerRequestCreatorDecoration($serverRequestCreator);\n }\n }\n\n throw new RuntimeException(\n \"Could not detect any ServerRequest creator implementations. \" .\n \"Please install a supported implementation in order to use `App::run()` \" .\n \"without having to pass in a `ServerRequest` object. \" .\n \"See https://github.com/slimphp/Slim/blob/4.x/README.md for a list of supported implementations.\"\n );\n }"} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":61,"symbol":"attemptServerRequestCreatorDecoration","kind":"method","lang":"php","code":"protected static function attemptServerRequestCreatorDecoration(\n ServerRequestCreatorInterface $serverRequestCreator\n ): ServerRequestCreatorInterface {\n if (\n static::$slimHttpDecoratorsAutomaticDetectionEnabled\n && SlimHttpServerRequestCreator::isServerRequestDecoratorAvailable()\n ) {\n return new SlimHttpServerRequestCreator($serverRequestCreator);\n }\n\n return $serverRequestCreator;\n }"} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":74,"symbol":"setPsr17FactoryProvider","kind":"method","lang":"php","code":"public static function setPsr17FactoryProvider(Psr17FactoryProviderInterface $psr17FactoryProvider): void\n {\n static::$psr17FactoryProvider = $psr17FactoryProvider;\n }"} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":79,"symbol":"setServerRequestCreator","kind":"method","lang":"php","code":"public static function setServerRequestCreator(ServerRequestCreatorInterface $serverRequestCreator): void\n {\n self::$serverRequestCreator = $serverRequestCreator;\n }"} {"repo":"slim","file":"Slim/Factory/ServerRequestCreatorFactory.php","line":84,"symbol":"setSlimHttpDecoratorsAutomaticDetection","kind":"method","lang":"php","code":"public static function setSlimHttpDecoratorsAutomaticDetection(bool $enabled): void\n {\n static::$slimHttpDecoratorsAutomaticDetectionEnabled = $enabled;\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":48,"symbol":"ErrorHandler","kind":"class","lang":"php","doc":"Default Slim application error handler It outputs the error message and diagnostic information in one of the following formats: JSON, XML, Plain Text or HTML based on the Accept header. @api","code":"class ErrorHandler implements ErrorHandlerInterface\n{\n protected string $defaultErrorRendererContentType = 'text/html';\n\n /**\n * @var ErrorRendererInterface|string|callable\n */\n protected $defaultErrorRenderer = HtmlErrorRenderer::class;\n\n /**\n * @var ErrorRendererInterface|string|callable\n */\n protected $logErrorRenderer = PlainTextErrorRenderer::class;\n\n /**\n * @var array\n */\n protected array $errorRenderers = [\n 'application/json' => JsonErrorRenderer::class,\n 'application/xml' => XmlErrorRenderer::class,\n 'text/xml' => XmlErrorRenderer::class,\n 'text/html' => HtmlErrorRenderer::class,\n 'text/plain' => PlainTextErrorRenderer::class,\n ];\n\n protected bool $displayErrorDetails = false;\n\n protected bool $logErrors;\n\n protected bool $logErrorDetails = false;\n\n protected ?string $contentType = null;\n\n protected bool $isContentTypeForced = false;\n\n protected ?string $method = null;\n\n protected ServerRequestInterface $request;\n\n protected Throwable $exception;\n\n protected int $statusCode;\n\n protected CallableResolverInterface $callableResolver;\n\n protected"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":97,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(\n CallableResolverInterface $callableResolver,\n ResponseFactoryInterface $responseFactory,\n ?LoggerInterface $logger = null\n ) {\n $this->callableResolver = $callableResolver;\n $this->responseFactory = $responseFactory;\n $this->logger = $logger ?: $this->getDefaultLogger();\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":116,"symbol":"__invoke","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request The most recent Request object @param Throwable $exception The caught Exception object @param bool $displayErrorDetails Whether or not to display the error details @param bool $logErrors Whether or not to log errors @param bool $logErrorDetails Whether or not to log error details","code":"public function __invoke(\n ServerRequestInterface $request,\n Throwable $exception,\n bool $displayErrorDetails,\n bool $logErrors,\n bool $logErrorDetails\n ): ResponseInterface {\n $this->displayErrorDetails = $displayErrorDetails;\n $this->logErrors = $logErrors;\n $this->logErrorDetails = $logErrorDetails;\n $this->request = $request;\n $this->exception = $exception;\n $this->method = $request->getMethod();\n $this->statusCode = $this->determineStatusCode();\n if (!$this->isContentTypeForced) {\n $this->contentType = $this->determineContentType($request);\n }\n\n if ($logErrors) {\n $this->writeToErrorLog();\n }\n\n return $this->respond();\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":146,"symbol":"forceContentType","kind":"method","lang":"php","doc":"Force the content type for all error handler responses. @param string|null $contentType The content type. Null restores Accept-header negotiation.","code":"public function forceContentType(?string $contentType): void\n {\n $this->isContentTypeForced = $contentType !== null;\n $this->contentType = $contentType;\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":152,"symbol":"determineStatusCode","kind":"method","lang":"php","code":"protected function determineStatusCode(): int\n {\n if ($this->method === 'OPTIONS') {\n return 200;\n }\n\n if ($this->exception instanceof HttpException) {\n return $this->exception->getCode();\n }\n\n return 500;\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":172,"symbol":"determineContentType","kind":"method","lang":"php","doc":"Determine which content type we know about is wanted using Accept header Note: This method is a bare-bones implementation designed specifically for Slim's error handling requirements. Consider a fully-feature solution such as willdurand/negotiation for any other situation.","code":"protected function determineContentType(ServerRequestInterface $request): ?string\n {\n $acceptHeader = $request->getHeaderLine('Accept');\n $selectedContentTypes = array_intersect(\n explode(',', $acceptHeader),\n array_keys($this->errorRenderers)\n );\n $count = count($selectedContentTypes);\n\n if ($count) {\n $current = current($selectedContentTypes);\n\n /**\n * Ensure other supported content types take precedence over text/plain\n * when multiple content types are provided via Accept header.\n */\n if ($current === 'text/plain' && $count > 1) {\n $next = next($selectedContentTypes);\n if (is_string($next)) {\n return $next;\n }\n }\n\n // @phpstan-ignore-next-line\n if (is_string($current)) {\n return $current;\n }\n }\n\n if (preg_match('/\\+(json|xml)/', $acceptHeader, $matches)) {\n $mediaType = 'application/' . $matches[1];\n if (array_key_exists($mediaType, $this->errorRenderers)) {\n return $mediaType;\n "} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":216,"symbol":"determineRenderer","kind":"method","lang":"php","doc":"Determine which renderer to use based on content type @throws RuntimeException","code":"protected function determineRenderer(): callable\n {\n if ($this->contentType !== null && array_key_exists($this->contentType, $this->errorRenderers)) {\n $renderer = $this->errorRenderers[$this->contentType];\n } else {\n $renderer = $this->defaultErrorRenderer;\n }\n\n return $this->callableResolver->resolve($renderer);\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":233,"symbol":"registerErrorRenderer","kind":"method","lang":"php","doc":"Register an error renderer for a specific content-type @param string $contentType The content-type this renderer should be registered to @param ErrorRendererInterface|string|callable $errorRenderer The error renderer","code":"public function registerErrorRenderer(string $contentType, $errorRenderer): void\n {\n $this->errorRenderers[$contentType] = $errorRenderer;\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":244,"symbol":"setDefaultErrorRenderer","kind":"method","lang":"php","doc":"Set the default error renderer @param string $contentType The content type of the default error renderer @param ErrorRendererInterface|string|callable $errorRenderer The default error renderer","code":"public function setDefaultErrorRenderer(string $contentType, $errorRenderer): void\n {\n $this->defaultErrorRendererContentType = $contentType;\n $this->defaultErrorRenderer = $errorRenderer;\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":255,"symbol":"setLogErrorRenderer","kind":"method","lang":"php","doc":"Set the renderer for the error logger @param ErrorRendererInterface|string|callable $logErrorRenderer","code":"public function setLogErrorRenderer($logErrorRenderer): void\n {\n $this->logErrorRenderer = $logErrorRenderer;\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":263,"symbol":"writeToErrorLog","kind":"method","lang":"php","doc":"Write to the error log if $logErrors has been set to true","code":"protected function writeToErrorLog(): void\n {\n $renderer = $this->callableResolver->resolve($this->logErrorRenderer);\n\n /** @var string $error */\n $error = $renderer($this->exception, $this->logErrorDetails);\n\n if ($this->logErrorRenderer === PlainTextErrorRenderer::class && !$this->displayErrorDetails) {\n $error .= \"\\nTips: To display error details in HTTP response \";\n $error .= 'set \"displayErrorDetails\" to true in the ErrorHandler constructor.';\n }\n\n $this->logError($error);\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":281,"symbol":"logError","kind":"method","lang":"php","doc":"Wraps the error_log function so that this can be easily tested","code":"protected function logError(string $error): void\n {\n $this->logger->error($error);\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":289,"symbol":"getDefaultLogger","kind":"method","lang":"php","doc":"Returns a default logger implementation.","code":"protected function getDefaultLogger(): LoggerInterface\n {\n return new Logger();\n }"} {"repo":"slim","file":"Slim/Handlers/ErrorHandler.php","line":294,"symbol":"respond","kind":"method","lang":"php","code":"protected function respond(): ResponseInterface\n {\n $response = $this->responseFactory->createResponse($this->statusCode);\n if ($this->contentType !== null && array_key_exists($this->contentType, $this->errorRenderers)) {\n $response = $response->withHeader('Content-type', $this->contentType);\n } else {\n $response = $response->withHeader('Content-type', $this->defaultErrorRendererContentType);\n }\n\n if ($this->exception instanceof HttpMethodNotAllowedException) {\n $allowedMethods = implode(', ', $this->exception->getAllowedMethods());\n $response = $response->withHeader('Allow', $allowedMethods);\n }\n\n $renderer = $this->determineRenderer();\n $body = call_user_func($renderer, $this->exception, $this->displayErrorDetails);\n if ($body !== false) {\n /** @var string $body */\n $response->getBody()->write($body);\n }\n\n return $response;\n }"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestHandler.php","line":20,"symbol":"RequestHandler","kind":"class","lang":"php","doc":"PSR-15 RequestHandler invocation strategy","code":"class RequestHandler implements RequestHandlerInvocationStrategyInterface\n{\n protected bool $appendRouteArgumentsToRequestAttributes;\n\n public function __construct(bool $appendRouteArgumentsToRequestAttributes = false)\n {\n $this->appendRouteArgumentsToRequestAttributes = $appendRouteArgumentsToRequestAttributes;\n }\n\n /**\n * Invoke a route callable that implements RequestHandlerInterface\n *\n * @param array $routeArguments\n */\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n if ($this->appendRouteArgumentsToRequestAttributes) {\n foreach ($routeArguments as $k => $v) {\n $request = $request->withAttribute($k, $v);\n }\n }\n\n /** @var ResponseInterface */\n return $callable($request);\n }\n}"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestHandler.php","line":24,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(bool $appendRouteArgumentsToRequestAttributes = false)\n {\n $this->appendRouteArgumentsToRequestAttributes = $appendRouteArgumentsToRequestAttributes;\n }"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestHandler.php","line":34,"symbol":"__invoke","kind":"method","lang":"php","doc":"Invoke a route callable that implements RequestHandlerInterface @param array $routeArguments","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n if ($this->appendRouteArgumentsToRequestAttributes) {\n foreach ($routeArguments as $k => $v) {\n $request = $request->withAttribute($k, $v);\n }\n }\n\n /** @var ResponseInterface */\n return $callable($request);\n }"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestResponse.php","line":20,"symbol":"RequestResponse","kind":"class","lang":"php","doc":"Default route callback strategy with route parameters as an array of arguments.","code":"class RequestResponse implements InvocationStrategyInterface\n{\n /**\n * Invoke a route callable with request, response, and all route parameters\n * as an array of arguments.\n *\n * @param array $routeArguments\n */\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n foreach ($routeArguments as $k => $v) {\n $request = $request->withAttribute($k, $v);\n }\n\n /** @var ResponseInterface */\n return $callable($request, $response, $routeArguments);\n }\n}"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestResponse.php","line":28,"symbol":"__invoke","kind":"method","lang":"php","doc":"Invoke a route callable with request, response, and all route parameters as an array of arguments. @param array $routeArguments","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n foreach ($routeArguments as $k => $v) {\n $request = $request->withAttribute($k, $v);\n }\n\n /** @var ResponseInterface */\n return $callable($request, $response, $routeArguments);\n }"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestResponseArgs.php","line":23,"symbol":"RequestResponseArgs","kind":"class","lang":"php","doc":"Route callback strategy with route parameters as individual arguments. @api","code":"class RequestResponseArgs implements InvocationStrategyInterface\n{\n /**\n * Invoke a route callable with request, response and all route parameters\n * as individual arguments.\n *\n * @param array $routeArguments\n */\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n /** @var ResponseInterface */\n return $callable($request, $response, ...array_values($routeArguments));\n }\n}"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestResponseArgs.php","line":31,"symbol":"__invoke","kind":"method","lang":"php","doc":"Invoke a route callable with request, response and all route parameters as individual arguments. @param array $routeArguments","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n /** @var ResponseInterface */\n return $callable($request, $response, ...array_values($routeArguments));\n }"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestResponseNamedArgs.php","line":22,"symbol":"RequestResponseNamedArgs","kind":"class","lang":"php","doc":"Route callback strategy with route parameters as individual arguments. @api","code":"class RequestResponseNamedArgs implements InvocationStrategyInterface\n{\n /**\n * Invoke a route callable with request, response and all route parameters\n * as individual arguments.\n *\n * @param array $routeArguments\n */\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n /** @var ResponseInterface */\n return $callable($request, $response, ...$routeArguments);\n }\n}"} {"repo":"slim","file":"Slim/Handlers/Strategies/RequestResponseNamedArgs.php","line":30,"symbol":"__invoke","kind":"method","lang":"php","doc":"Invoke a route callable with request, response and all route parameters as individual arguments. @param array $routeArguments","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n /** @var ResponseInterface */\n return $callable($request, $response, ...$routeArguments);\n }"} {"repo":"slim","file":"Slim/Interfaces/AdvancedCallableResolverInterface.php","line":13,"symbol":"AdvancedCallableResolverInterface","kind":"interface","lang":"php","code":"interface AdvancedCallableResolverInterface extends CallableResolverInterface\n{\n /**\n * Resolve $toResolve into a callable\n *\n * @param callable|array{class-string, string}|string $toResolve\n */\n public function resolveRoute($toResolve): callable;\n\n /**\n * Resolve $toResolve into a callable\n *\n * @param callable|array{class-string, string}|string $toResolve\n */\n public function resolveMiddleware($toResolve): callable;\n}"} {"repo":"slim","file":"Slim/Interfaces/AdvancedCallableResolverInterface.php","line":20,"symbol":"resolveRoute","kind":"method","lang":"php","doc":"Resolve $toResolve into a callable @param callable|array{class-string, string}|string $toResolve","code":"public function resolveRoute($toResolve): callable;"} {"repo":"slim","file":"Slim/Interfaces/AdvancedCallableResolverInterface.php","line":27,"symbol":"resolveMiddleware","kind":"method","lang":"php","doc":"Resolve $toResolve into a callable @param callable|array{class-string, string}|string $toResolve","code":"public function resolveMiddleware($toResolve): callable;"} {"repo":"slim","file":"Slim/Interfaces/CallableResolverInterface.php","line":13,"symbol":"CallableResolverInterface","kind":"interface","lang":"php","code":"interface CallableResolverInterface\n{\n /**\n * Resolve $toResolve into a callable\n *\n * @param callable|array{class-string, string}|string $toResolve\n */\n public function resolve($toResolve): callable;\n}"} {"repo":"slim","file":"Slim/Interfaces/CallableResolverInterface.php","line":20,"symbol":"resolve","kind":"method","lang":"php","doc":"Resolve $toResolve into a callable @param callable|array{class-string, string}|string $toResolve","code":"public function resolve($toResolve): callable;"} {"repo":"slim","file":"Slim/Interfaces/DispatcherInterface.php","line":15,"symbol":"DispatcherInterface","kind":"interface","lang":"php","code":"interface DispatcherInterface\n{\n /**\n * Get routing results for a given request method and uri\n */\n public function dispatch(string $method, string $uri): RoutingResults;\n\n /**\n * Get allowed methods for a given uri\n *\n * @return string[]\n */\n public function getAllowedMethods(string $uri): array;\n}"} {"repo":"slim","file":"Slim/Interfaces/DispatcherInterface.php","line":20,"symbol":"dispatch","kind":"method","lang":"php","doc":"Get routing results for a given request method and uri","code":"public function dispatch(string $method, string $uri): RoutingResults;"} {"repo":"slim","file":"Slim/Interfaces/DispatcherInterface.php","line":27,"symbol":"getAllowedMethods","kind":"method","lang":"php","doc":"Get allowed methods for a given uri @return string[]","code":"public function getAllowedMethods(string $uri): array;"} {"repo":"slim","file":"Slim/Interfaces/ErrorHandlerInterface.php","line":17,"symbol":"ErrorHandlerInterface","kind":"interface","lang":"php","code":"interface ErrorHandlerInterface\n{\n public function __invoke(\n ServerRequestInterface $request,\n Throwable $exception,\n bool $displayErrorDetails,\n bool $logErrors,\n bool $logErrorDetails\n ): ResponseInterface;\n}"} {"repo":"slim","file":"Slim/Interfaces/ErrorHandlerInterface.php","line":19,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(\n ServerRequestInterface $request,\n Throwable $exception,\n bool $displayErrorDetails,\n bool $logErrors,\n bool $logErrorDetails\n ): ResponseInterface;"} {"repo":"slim","file":"Slim/Interfaces/ErrorRendererInterface.php","line":15,"symbol":"ErrorRendererInterface","kind":"interface","lang":"php","code":"interface ErrorRendererInterface\n{\n public function __invoke(Throwable $exception, bool $displayErrorDetails): string;\n}"} {"repo":"slim","file":"Slim/Interfaces/ErrorRendererInterface.php","line":17,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(Throwable $exception, bool $displayErrorDetails): string;"} {"repo":"slim","file":"Slim/Interfaces/InvocationStrategyInterface.php","line":19,"symbol":"InvocationStrategyInterface","kind":"interface","lang":"php","doc":"Defines a contract for invoking a route callable.","code":"interface InvocationStrategyInterface\n{\n /**\n * Invoke a route callable.\n *\n * @param callable $callable The callable to invoke using the strategy.\n * @param ServerRequestInterface $request The request object.\n * @param ResponseInterface $response The response object.\n * @param array $routeArguments The route's placeholder arguments\n *\n * @return ResponseInterface The response from the callable.\n */\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface;\n}"} {"repo":"slim","file":"Slim/Interfaces/InvocationStrategyInterface.php","line":31,"symbol":"__invoke","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request The request object. @param ResponseInterface $response The response object. @param array $routeArguments The route's placeholder arguments @return ResponseInterface The response from the callable.","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface;"} {"repo":"slim","file":"Slim/Interfaces/MiddlewareDispatcherInterface.php","line":17,"symbol":"MiddlewareDispatcherInterface","kind":"interface","lang":"php","doc":"@api","code":"interface MiddlewareDispatcherInterface extends RequestHandlerInterface\n{\n /**\n * Add a new middleware to the stack\n *\n * Middleware are organized as a stack. That means middleware\n * that have been added before will be executed after the newly\n * added one (last in, first out).\n *\n * @param MiddlewareInterface|string|callable $middleware\n */\n public function add($middleware): self;\n\n /**\n * Add a new middleware to the stack\n *\n * Middleware are organized as a stack. That means middleware\n * that have been added before will be executed after the newly\n * added one (last in, first out).\n */\n public function addMiddleware(MiddlewareInterface $middleware): self;\n\n /**\n * Seed the middleware stack with the inner request handler\n */\n public function seedMiddlewareStack(RequestHandlerInterface $kernel): void;\n}"} {"repo":"slim","file":"Slim/Interfaces/MiddlewareDispatcherInterface.php","line":28,"symbol":"add","kind":"method","lang":"php","doc":"Middleware are organized as a stack. That means middleware that have been added before will be executed after the newly added one (last in, first out). @param MiddlewareInterface|string|callable $middleware","code":"public function add($middleware): self;"} {"repo":"slim","file":"Slim/Interfaces/MiddlewareDispatcherInterface.php","line":37,"symbol":"addMiddleware","kind":"method","lang":"php","doc":"Add a new middleware to the stack Middleware are organized as a stack. That means middleware that have been added before will be executed after the newly added one (last in, first out).","code":"public function addMiddleware(MiddlewareInterface $middleware): self;"} {"repo":"slim","file":"Slim/Interfaces/MiddlewareDispatcherInterface.php","line":42,"symbol":"seedMiddlewareStack","kind":"method","lang":"php","doc":"Seed the middleware stack with the inner request handler","code":"public function seedMiddlewareStack(RequestHandlerInterface $kernel): void;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":17,"symbol":"Psr17FactoryInterface","kind":"interface","lang":"php","code":"interface Psr17FactoryInterface\n{\n /**\n * @throws RuntimeException when the factory could not be instantiated\n */\n public static function getResponseFactory(): ResponseFactoryInterface;\n\n /**\n * @throws RuntimeException when the factory could not be instantiated\n */\n public static function getStreamFactory(): StreamFactoryInterface;\n\n /**\n * @throws RuntimeException when the factory could not be instantiated\n */\n public static function getServerRequestCreator(): ServerRequestCreatorInterface;\n\n /**\n * Is the PSR-17 ResponseFactory available\n */\n public static function isResponseFactoryAvailable(): bool;\n\n /**\n * Is the PSR-17 StreamFactory available\n */\n public static function isStreamFactoryAvailable(): bool;\n\n /**\n * Is the ServerRequest creator available\n */\n public static function isServerRequestCreatorAvailable(): bool;\n}"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":22,"symbol":"getResponseFactory","kind":"method","lang":"php","doc":"@throws RuntimeException when the factory could not be instantiated","code":"public static function getResponseFactory(): ResponseFactoryInterface;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":27,"symbol":"getStreamFactory","kind":"method","lang":"php","doc":"@throws RuntimeException when the factory could not be instantiated","code":"public static function getStreamFactory(): StreamFactoryInterface;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":32,"symbol":"getServerRequestCreator","kind":"method","lang":"php","doc":"@throws RuntimeException when the factory could not be instantiated","code":"public static function getServerRequestCreator(): ServerRequestCreatorInterface;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":37,"symbol":"isResponseFactoryAvailable","kind":"method","lang":"php","doc":"Is the PSR-17 ResponseFactory available","code":"public static function isResponseFactoryAvailable(): bool;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":42,"symbol":"isStreamFactoryAvailable","kind":"method","lang":"php","doc":"Is the PSR-17 StreamFactory available","code":"public static function isStreamFactoryAvailable(): bool;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryInterface.php","line":47,"symbol":"isServerRequestCreatorAvailable","kind":"method","lang":"php","doc":"Is the ServerRequest creator available","code":"public static function isServerRequestCreatorAvailable(): bool;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryProviderInterface.php","line":14,"symbol":"Psr17FactoryProviderInterface","kind":"interface","lang":"php","doc":"@api","code":"interface Psr17FactoryProviderInterface\n{\n /**\n * @return string[]\n */\n public static function getFactories(): array;\n\n /**\n * @param string[] $factories\n */\n public static function setFactories(array $factories): void;\n\n public static function addFactory(string $factory): void;\n}"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryProviderInterface.php","line":19,"symbol":"getFactories","kind":"method","lang":"php","doc":"@return string[]","code":"public static function getFactories(): array;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryProviderInterface.php","line":24,"symbol":"setFactories","kind":"method","lang":"php","doc":"@param string[] $factories","code":"public static function setFactories(array $factories): void;"} {"repo":"slim","file":"Slim/Interfaces/Psr17FactoryProviderInterface.php","line":26,"symbol":"addFactory","kind":"method","lang":"php","code":"public static function addFactory(string $factory): void;"} {"repo":"slim","file":"Slim/Interfaces/RequestHandlerInvocationStrategyInterface.php","line":13,"symbol":"RequestHandlerInvocationStrategyInterface","kind":"interface","lang":"php","code":"interface RequestHandlerInvocationStrategyInterface extends InvocationStrategyInterface\n{\n}"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":17,"symbol":"RouteCollectorInterface","kind":"interface","lang":"php","doc":"@api","code":"interface RouteCollectorInterface\n{\n /**\n * Get the route parser\n */\n public function getRouteParser(): RouteParserInterface;\n\n /**\n * Get default route invocation strategy\n */\n public function getDefaultInvocationStrategy(): InvocationStrategyInterface;\n\n /**\n * Set default route invocation strategy\n */\n public function setDefaultInvocationStrategy(InvocationStrategyInterface $strategy): RouteCollectorInterface;\n\n /**\n * Get path to FastRoute cache file\n */\n public function getCacheFile(): ?string;\n\n /**\n * Set path to FastRoute cache file\n *\n * @throws InvalidArgumentException\n * @throws RuntimeException\n */\n public function setCacheFile(string $cacheFile): RouteCollectorInterface;\n\n /**\n * Get the base path used in pathFor()\n */\n public function getBasePath(): string;\n\n /**\n * Set the base path used in pathFor()\n */\n public function setBasePath(string $basePath): RouteCollectorInterface;\n\n /**\n * Get route objects\n *\n * @return RouteInterface[]\n */\n public function getRoutes(): array;\n\n /**\n * Get named route object\n *\n * @param strin"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":22,"symbol":"getRouteParser","kind":"method","lang":"php","doc":"Get the route parser","code":"public function getRouteParser(): RouteParserInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":27,"symbol":"getDefaultInvocationStrategy","kind":"method","lang":"php","doc":"Get default route invocation strategy","code":"public function getDefaultInvocationStrategy(): InvocationStrategyInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":32,"symbol":"setDefaultInvocationStrategy","kind":"method","lang":"php","doc":"Set default route invocation strategy","code":"public function setDefaultInvocationStrategy(InvocationStrategyInterface $strategy): RouteCollectorInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":37,"symbol":"getCacheFile","kind":"method","lang":"php","doc":"Get path to FastRoute cache file","code":"public function getCacheFile(): ?string;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":45,"symbol":"setCacheFile","kind":"method","lang":"php","doc":"Set path to FastRoute cache file @throws InvalidArgumentException @throws RuntimeException","code":"public function setCacheFile(string $cacheFile): RouteCollectorInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":50,"symbol":"getBasePath","kind":"method","lang":"php","doc":"Get the base path used in pathFor()","code":"public function getBasePath(): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":55,"symbol":"setBasePath","kind":"method","lang":"php","doc":"Set the base path used in pathFor()","code":"public function setBasePath(string $basePath): RouteCollectorInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":62,"symbol":"getRoutes","kind":"method","lang":"php","doc":"Get route objects @return RouteInterface[]","code":"public function getRoutes(): array;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":71,"symbol":"getNamedRoute","kind":"method","lang":"php","doc":"Get named route object @param string $name Route name @throws RuntimeException If named route does not exist","code":"public function getNamedRoute(string $name): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":80,"symbol":"removeNamedRoute","kind":"method","lang":"php","doc":"Remove named route @param string $name Route name @throws RuntimeException If named route does not exist","code":"public function removeNamedRoute(string $name): RouteCollectorInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":87,"symbol":"lookupRoute","kind":"method","lang":"php","doc":"Lookup a route via the route's unique identifier @throws RuntimeException If route of identifier does not exist","code":"public function lookupRoute(string $identifier): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":93,"symbol":"group","kind":"method","lang":"php","doc":"Add route group @param string|callable $callable","code":"public function group(string $pattern, $callable): RouteGroupInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorInterface.php","line":102,"symbol":"map","kind":"method","lang":"php","doc":"Add route @param string[] $methods Array of HTTP methods @param string $pattern The route pattern @param callable|array{class-string, string}|string $handler The route callable","code":"public function map(array $methods, string $pattern, $handler): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":21,"symbol":"RouteCollectorProxyInterface","kind":"interface","lang":"php","doc":"@api @template TContainerInterface of (ContainerInterface|null)","code":"interface RouteCollectorProxyInterface\n{\n public function getResponseFactory(): ResponseFactoryInterface;\n\n public function getCallableResolver(): CallableResolverInterface;\n\n /**\n * @return TContainerInterface\n */\n public function getContainer(): ?ContainerInterface;\n\n public function getRouteCollector(): RouteCollectorInterface;\n\n /**\n * Get the RouteCollectorProxy's base path\n */\n public function getBasePath(): string;\n\n /**\n * Set the RouteCollectorProxy's base path\n * @return RouteCollectorProxyInterface\n */\n public function setBasePath(string $basePath): RouteCollectorProxyInterface;\n\n /**\n * Add GET route\n *\n * @param string $pattern The route URI pattern\n * @param callable|array{class-string, string}|string $callable The route callback routine\n */\n public function get(string $pattern, $callable): RouteInterface;\n\n /**\n * Add POST route\n *\n * @param string $pattern The route URI pattern\n * @param callable|array{class-string, string}|string $callable The route callback routine\n */\n public function post(string $pattern, $callable): RouteInterface;\n\n "} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":23,"symbol":"getResponseFactory","kind":"method","lang":"php","code":"public function getResponseFactory(): ResponseFactoryInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":25,"symbol":"getCallableResolver","kind":"method","lang":"php","code":"public function getCallableResolver(): CallableResolverInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":30,"symbol":"getContainer","kind":"method","lang":"php","doc":"@return TContainerInterface","code":"public function getContainer(): ?ContainerInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":32,"symbol":"getRouteCollector","kind":"method","lang":"php","code":"public function getRouteCollector(): RouteCollectorInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":37,"symbol":"getBasePath","kind":"method","lang":"php","doc":"Get the RouteCollectorProxy's base path","code":"public function getBasePath(): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":43,"symbol":"setBasePath","kind":"method","lang":"php","doc":"Set the RouteCollectorProxy's base path @return RouteCollectorProxyInterface","code":"public function setBasePath(string $basePath): RouteCollectorProxyInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":51,"symbol":"get","kind":"method","lang":"php","doc":"Add GET route @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function get(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":59,"symbol":"post","kind":"method","lang":"php","doc":"Add POST route @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function post(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":67,"symbol":"put","kind":"method","lang":"php","doc":"Add PUT route @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function put(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":75,"symbol":"patch","kind":"method","lang":"php","doc":"Add PATCH route @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function patch(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":83,"symbol":"delete","kind":"method","lang":"php","doc":"Add DELETE route @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function delete(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":91,"symbol":"options","kind":"method","lang":"php","doc":"Add OPTIONS route @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function options(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":99,"symbol":"any","kind":"method","lang":"php","doc":"Add route for any HTTP method @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function any(string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":108,"symbol":"map","kind":"method","lang":"php","doc":"Add route with multiple methods @param string[] $methods Numeric array of HTTP method names @param string $pattern The route URI pattern @param callable|array{class-string, string}|string $callable The route callback routine","code":"public function map(array $methods, string $pattern, $callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":118,"symbol":"group","kind":"method","lang":"php","doc":"This method accepts a route pattern and a callback. All route declarations in the callback will be prepended by the group(s) that it is in. @param string|callable $callable","code":"public function group(string $pattern, $callable): RouteGroupInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteCollectorProxyInterface.php","line":125,"symbol":"redirect","kind":"method","lang":"php","doc":"Add a route that sends an HTTP redirect @param string|UriInterface $to","code":"public function redirect(string $from, $to, int $status = 302): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteGroupInterface.php","line":17,"symbol":"RouteGroupInterface","kind":"interface","lang":"php","doc":"@api","code":"interface RouteGroupInterface\n{\n public function collectRoutes(): RouteGroupInterface;\n\n /**\n * Add middleware to the route group\n *\n * @param MiddlewareInterface|string|callable $middleware\n */\n public function add($middleware): RouteGroupInterface;\n\n /**\n * Add middleware to the route group\n */\n public function addMiddleware(MiddlewareInterface $middleware): RouteGroupInterface;\n\n /**\n * Append the group's middleware to the MiddlewareDispatcher\n * @param MiddlewareDispatcher<\\Psr\\Container\\ContainerInterface|null> $dispatcher\n */\n public function appendMiddlewareToDispatcher(MiddlewareDispatcher $dispatcher): RouteGroupInterface;\n\n /**\n * Get the RouteGroup's pattern\n */\n public function getPattern(): string;\n}"} {"repo":"slim","file":"Slim/Interfaces/RouteGroupInterface.php","line":19,"symbol":"collectRoutes","kind":"method","lang":"php","code":"public function collectRoutes(): RouteGroupInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteGroupInterface.php","line":26,"symbol":"add","kind":"method","lang":"php","doc":"Add middleware to the route group @param MiddlewareInterface|string|callable $middleware","code":"public function add($middleware): RouteGroupInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteGroupInterface.php","line":31,"symbol":"addMiddleware","kind":"method","lang":"php","doc":"Add middleware to the route group","code":"public function addMiddleware(MiddlewareInterface $middleware): RouteGroupInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteGroupInterface.php","line":37,"symbol":"appendMiddlewareToDispatcher","kind":"method","lang":"php","doc":"Append the group's middleware to the MiddlewareDispatcher @param MiddlewareDispatcher<\\Psr\\Container\\ContainerInterface|null> $dispatcher","code":"public function appendMiddlewareToDispatcher(MiddlewareDispatcher $dispatcher): RouteGroupInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteGroupInterface.php","line":42,"symbol":"getPattern","kind":"method","lang":"php","doc":"Get the RouteGroup's pattern","code":"public function getPattern(): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":18,"symbol":"RouteInterface","kind":"interface","lang":"php","doc":"@api","code":"interface RouteInterface\n{\n /**\n * Get route invocation strategy\n */\n public function getInvocationStrategy(): InvocationStrategyInterface;\n\n /**\n * Set route invocation strategy\n */\n public function setInvocationStrategy(InvocationStrategyInterface $invocationStrategy): RouteInterface;\n\n /**\n * Get route methods\n *\n * @return string[]\n */\n public function getMethods(): array;\n\n /**\n * Get route pattern\n */\n public function getPattern(): string;\n\n /**\n * Set route pattern\n */\n public function setPattern(string $pattern): RouteInterface;\n\n /**\n * Get route callable\n *\n * @return callable|array{class-string, string}|string\n */\n public function getCallable();\n\n /**\n * Set route callable\n *\n * @param callable|array{class-string, string}|string $callable\n */\n public function setCallable($callable): RouteInterface;\n\n /**\n * Get route name\n */\n public function getName(): ?string;\n\n /**\n * Set route name\n *\n * @return static\n */\n public function setName(string $name): RouteInterface;\n\n /**\n * Get the route's unique identifier\n "} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":23,"symbol":"getInvocationStrategy","kind":"method","lang":"php","doc":"Get route invocation strategy","code":"public function getInvocationStrategy(): InvocationStrategyInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":28,"symbol":"setInvocationStrategy","kind":"method","lang":"php","doc":"Set route invocation strategy","code":"public function setInvocationStrategy(InvocationStrategyInterface $invocationStrategy): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":35,"symbol":"getMethods","kind":"method","lang":"php","doc":"Get route methods @return string[]","code":"public function getMethods(): array;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":40,"symbol":"getPattern","kind":"method","lang":"php","doc":"Get route pattern","code":"public function getPattern(): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":45,"symbol":"setPattern","kind":"method","lang":"php","doc":"Set route pattern","code":"public function setPattern(string $pattern): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":52,"symbol":"getCallable","kind":"method","lang":"php","doc":"Get route callable @return callable|array{class-string, string}|string","code":"public function getCallable();"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":59,"symbol":"setCallable","kind":"method","lang":"php","doc":"Set route callable @param callable|array{class-string, string}|string $callable","code":"public function setCallable($callable): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":64,"symbol":"getName","kind":"method","lang":"php","doc":"Get route name","code":"public function getName(): ?string;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":71,"symbol":"setName","kind":"method","lang":"php","doc":"Set route name @return static","code":"public function setName(string $name): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":76,"symbol":"getIdentifier","kind":"method","lang":"php","doc":"Get the route's unique identifier","code":"public function getIdentifier(): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":81,"symbol":"getArgument","kind":"method","lang":"php","doc":"Retrieve a specific route argument","code":"public function getArgument(string $name, ?string $default = null): ?string;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":88,"symbol":"getArguments","kind":"method","lang":"php","doc":"Get route arguments @return array","code":"public function getArguments(): array;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":95,"symbol":"setArgument","kind":"method","lang":"php","doc":"Set a route argument @deprecated 4.14.1 Use a middleware for custom route arguments now.","code":"public function setArgument(string $name, string $value): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":104,"symbol":"setArguments","kind":"method","lang":"php","doc":"Replace route arguments @param array $arguments @deprecated 4.14.1 Use a middleware for custom route arguments now.","code":"public function setArguments(array $arguments): self;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":109,"symbol":"add","kind":"method","lang":"php","doc":"@param MiddlewareInterface|string|callable $middleware","code":"public function add($middleware): self;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":111,"symbol":"addMiddleware","kind":"method","lang":"php","code":"public function addMiddleware(MiddlewareInterface $middleware): self;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":118,"symbol":"prepare","kind":"method","lang":"php","doc":"Prepare the route for use @param array $arguments","code":"public function prepare(array $arguments): self;"} {"repo":"slim","file":"Slim/Interfaces/RouteInterface.php","line":127,"symbol":"run","kind":"method","lang":"php","doc":"Run route This method traverses the middleware stack, including the route's callable and captures the resultant HTTP response object. It then sends the response back to the Application.","code":"public function run(ServerRequestInterface $request): ResponseInterface;"} {"repo":"slim","file":"Slim/Interfaces/RouteParserInterface.php","line":18,"symbol":"RouteParserInterface","kind":"interface","lang":"php","doc":"@api","code":"interface RouteParserInterface\n{\n /**\n * Build the path for a named route excluding the base path\n *\n * @param string $routeName Route name\n * @param array $data Named argument replacement data\n * @param array> $queryParams Optional query string parameters\n *\n * @throws RuntimeException If named route does not exist\n * @throws InvalidArgumentException If required data not provided\n */\n public function relativeUrlFor(string $routeName, array $data = [], array $queryParams = []): string;\n\n /**\n * Build the path for a named route including the base path\n *\n * @param string $routeName Route name\n * @param array $data Named argument replacement data\n * @param array> $queryParams Optional query string parameters\n *\n * @throws RuntimeException If named route does not exist\n * @throws InvalidArgumentException If required data not p"} {"repo":"slim","file":"Slim/Interfaces/RouteParserInterface.php","line":30,"symbol":"relativeUrlFor","kind":"method","lang":"php","doc":"@param array $data Named argument replacement data @param array> $queryParams Optional query string parameters @throws RuntimeException If named route does not exist @throws InvalidArgumentException If required data not provided","code":"public function relativeUrlFor(string $routeName, array $data = [], array $queryParams = []): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteParserInterface.php","line":42,"symbol":"urlFor","kind":"method","lang":"php","doc":"@param array $data Named argument replacement data @param array> $queryParams Optional query string parameters @throws RuntimeException If named route does not exist @throws InvalidArgumentException If required data not provided","code":"public function urlFor(string $routeName, array $data = [], array $queryParams = []): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteParserInterface.php","line":52,"symbol":"fullUrlFor","kind":"method","lang":"php","doc":"@param UriInterface $uri @param string $routeName Route name @param array $data Named argument replacement data @param array> $queryParams Optional query string parameters","code":"public function fullUrlFor(UriInterface $uri, string $routeName, array $data = [], array $queryParams = []): string;"} {"repo":"slim","file":"Slim/Interfaces/RouteResolverInterface.php","line":9,"symbol":"RouteResolverInterface","kind":"interface","lang":"php","code":"interface RouteResolverInterface\n{\n /**\n * @param string $uri Should be ServerRequestInterface::getUri()->getPath()\n */\n public function computeRoutingResults(string $uri, string $method): RoutingResults;\n\n public function resolveRoute(string $identifier): RouteInterface;\n}"} {"repo":"slim","file":"Slim/Interfaces/RouteResolverInterface.php","line":14,"symbol":"computeRoutingResults","kind":"method","lang":"php","doc":"@param string $uri Should be ServerRequestInterface::getUri()->getPath()","code":"public function computeRoutingResults(string $uri, string $method): RoutingResults;"} {"repo":"slim","file":"Slim/Interfaces/RouteResolverInterface.php","line":16,"symbol":"resolveRoute","kind":"method","lang":"php","code":"public function resolveRoute(string $identifier): RouteInterface;"} {"repo":"slim","file":"Slim/Interfaces/ServerRequestCreatorInterface.php","line":15,"symbol":"ServerRequestCreatorInterface","kind":"interface","lang":"php","code":"interface ServerRequestCreatorInterface\n{\n public function createServerRequestFromGlobals(): ServerRequestInterface;\n}"} {"repo":"slim","file":"Slim/Interfaces/ServerRequestCreatorInterface.php","line":17,"symbol":"createServerRequestFromGlobals","kind":"method","lang":"php","code":"public function createServerRequestFromGlobals(): ServerRequestInterface;"} {"repo":"slim","file":"Slim/Logger.php","line":19,"symbol":"Logger","kind":"class","lang":"php","code":"class Logger extends AbstractLogger\n{\n /**\n * @param mixed $level\n * @param string|Stringable $message\n * @param array $context\n *\n * @throws InvalidArgumentException\n */\n public function log($level, $message, array $context = []): void\n {\n error_log((string) $message);\n }\n}"} {"repo":"slim","file":"Slim/Logger.php","line":28,"symbol":"log","kind":"method","lang":"php","doc":"@param mixed $level @param string|Stringable $message @param array $context @throws InvalidArgumentException","code":"public function log($level, $message, array $context = []): void\n {\n error_log((string) $message);\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":36,"symbol":"BodyParsingMiddleware","kind":"class","lang":"php","doc":"@api","code":"class BodyParsingMiddleware implements MiddlewareInterface\n{\n /**\n * @var callable[]\n */\n protected array $bodyParsers;\n\n /**\n * @param callable[] $bodyParsers list of body parsers as an associative array of mediaType => callable\n */\n public function __construct(array $bodyParsers = [])\n {\n $this->registerDefaultBodyParsers();\n\n foreach ($bodyParsers as $mediaType => $parser) {\n $this->registerBodyParser($mediaType, $parser);\n }\n }\n\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $parsedBody = $request->getParsedBody();\n\n if (empty($parsedBody)) {\n $parsedBody = $this->parseBody($request);\n $request = $request->withParsedBody($parsedBody);\n }\n\n return $handler->handle($request);\n }\n\n /**\n * @param string $mediaType A HTTP media type (excluding content-type params).\n * @param callable $callable A callable that returns parsed contents for media type.\n */\n public function registerBodyParser(string $mediaType, callable $callable): self\n {\n $this->bodyParsers[$mediaType]"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":46,"symbol":"__construct","kind":"method","lang":"php","doc":"@param callable[] $bodyParsers list of body parsers as an associative array of mediaType => callable","code":"public function __construct(array $bodyParsers = [])\n {\n $this->registerDefaultBodyParsers();\n\n foreach ($bodyParsers as $mediaType => $parser) {\n $this->registerBodyParser($mediaType, $parser);\n }\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":55,"symbol":"process","kind":"method","lang":"php","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $parsedBody = $request->getParsedBody();\n\n if (empty($parsedBody)) {\n $parsedBody = $this->parseBody($request);\n $request = $request->withParsedBody($parsedBody);\n }\n\n return $handler->handle($request);\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":71,"symbol":"registerBodyParser","kind":"method","lang":"php","doc":"@param string $mediaType A HTTP media type (excluding content-type params). @param callable $callable A callable that returns parsed contents for media type.","code":"public function registerBodyParser(string $mediaType, callable $callable): self\n {\n $this->bodyParsers[$mediaType] = $callable;\n return $this;\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":80,"symbol":"hasBodyParser","kind":"method","lang":"php","doc":"@param string $mediaType A HTTP media type (excluding content-type params).","code":"public function hasBodyParser(string $mediaType): bool\n {\n return isset($this->bodyParsers[$mediaType]);\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":89,"symbol":"getBodyParser","kind":"method","lang":"php","doc":"@param string $mediaType A HTTP media type (excluding content-type params). @throws RuntimeException","code":"public function getBodyParser(string $mediaType): callable\n {\n if (!isset($this->bodyParsers[$mediaType])) {\n throw new RuntimeException('No parser for type ' . $mediaType);\n }\n return $this->bodyParsers[$mediaType];\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":97,"symbol":"registerDefaultBodyParsers","kind":"method","lang":"php","code":"protected function registerDefaultBodyParsers(): void\n {\n $this->registerBodyParser('application/json', static function ($input) {\n /** @var string $input */\n $result = json_decode($input, true);\n\n if (!is_array($result)) {\n return null;\n }\n\n return $result;\n });\n\n $this->registerBodyParser('application/x-www-form-urlencoded', static function ($input) {\n /** @var string $input */\n parse_str($input, $data);\n\n return $data;\n });\n\n $xmlCallable = static function ($input) {\n /** @var string $input */\n\n $backup = self::disableXmlEntityLoader(true);\n $backup_errors = libxml_use_internal_errors(true);\n $result = simplexml_load_string($input);\n\n self::disableXmlEntityLoader($backup);\n libxml_clear_errors();\n libxml_use_internal_errors($backup_errors);\n\n if ($result === false) {\n return null;\n }\n\n return $result;\n };\n\n $this->registerBodyParser('application/xml', $xmlCallable);\n $this->registerBodyParser('tex"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":142,"symbol":"parseBody","kind":"method","lang":"php","doc":"@return null|array|object","code":"protected function parseBody(ServerRequestInterface $request)\n {\n $mediaType = $this->getMediaType($request);\n if ($mediaType === null) {\n return null;\n }\n\n // Check if this specific media type has a parser registered first\n if (!isset($this->bodyParsers[$mediaType])) {\n // If not, look for a media type with a structured syntax suffix (RFC 6839)\n $parts = explode('+', $mediaType);\n if (count($parts) >= 2) {\n $mediaType = 'application/' . $parts[count($parts) - 1];\n }\n }\n\n if (isset($this->bodyParsers[$mediaType])) {\n $body = (string)$request->getBody();\n $parsed = $this->bodyParsers[$mediaType]($body);\n\n if ($parsed !== null && !is_object($parsed) && !is_array($parsed)) {\n throw new RuntimeException(\n 'Request body media type parser return value must be an array, an object, or null'\n );\n }\n\n return $parsed;\n }\n\n return null;\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":177,"symbol":"getMediaType","kind":"method","lang":"php","doc":"@return string|null The serverRequest media type, minus content-type params","code":"protected function getMediaType(ServerRequestInterface $request): ?string\n {\n $contentType = $request->getHeader('Content-Type')[0] ?? null;\n\n if (is_string($contentType) && trim($contentType) !== '') {\n $contentTypeParts = explode(';', $contentType);\n return strtolower(trim($contentTypeParts[0]));\n }\n\n return null;\n }"} {"repo":"slim","file":"Slim/Middleware/BodyParsingMiddleware.php","line":189,"symbol":"disableXmlEntityLoader","kind":"method","lang":"php","code":"protected static function disableXmlEntityLoader(bool $disable): bool\n {\n if (LIBXML_VERSION >= 20900) {\n // libxml >= 2.9.0 disables entity loading by default, so it is\n // safe to skip the real call (deprecated in PHP 8).\n return true;\n }\n\n // @codeCoverageIgnoreStart\n return libxml_disable_entity_loader($disable);\n // @codeCoverageIgnoreEnd\n }"} {"repo":"slim","file":"Slim/Middleware/ContentLengthMiddleware.php","line":19,"symbol":"ContentLengthMiddleware","kind":"class","lang":"php","doc":"@api","code":"class ContentLengthMiddleware implements MiddlewareInterface\n{\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $response = $handler->handle($request);\n\n // Add Content-Length header if not already added\n $size = $response->getBody()->getSize();\n if ($size !== null && !$response->hasHeader('Content-Length')) {\n $response = $response->withHeader('Content-Length', (string) $size);\n }\n\n return $response;\n }\n}"} {"repo":"slim","file":"Slim/Middleware/ContentLengthMiddleware.php","line":21,"symbol":"process","kind":"method","lang":"php","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $response = $handler->handle($request);\n\n // Add Content-Length header if not already added\n $size = $response->getBody()->getSize();\n if ($size !== null && !$response->hasHeader('Content-Length')) {\n $response = $response->withHeader('Content-Length', (string) $size);\n }\n\n return $response;\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":29,"symbol":"ErrorMiddleware","kind":"class","lang":"php","doc":"@api","code":"class ErrorMiddleware implements MiddlewareInterface\n{\n protected CallableResolverInterface $callableResolver;\n\n protected ResponseFactoryInterface $responseFactory;\n\n protected bool $displayErrorDetails;\n\n protected bool $logErrors;\n\n protected bool $logErrorDetails;\n\n protected ?LoggerInterface $logger = null;\n\n /**\n * @var ErrorHandlerInterface[]|callable[]|string[]\n */\n protected array $handlers = [];\n\n /**\n * @var ErrorHandlerInterface[]|callable[]|string[]\n */\n protected array $subClassHandlers = [];\n\n /**\n * @var ErrorHandlerInterface|callable|string|null\n */\n protected $defaultErrorHandler;\n\n public function __construct(\n CallableResolverInterface $callableResolver,\n ResponseFactoryInterface $responseFactory,\n bool $displayErrorDetails,\n bool $logErrors,\n bool $logErrorDetails,\n ?LoggerInterface $logger = null\n ) {\n $this->callableResolver = $callableResolver;\n $this->responseFactory = $responseFactory;\n $this->displayErrorDetails = $displayErrorDetails;\n $this->logErrors = $logErrors;\n $this->logErrorDetails = $logErrorDetails;\n "} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":58,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(\n CallableResolverInterface $callableResolver,\n ResponseFactoryInterface $responseFactory,\n bool $displayErrorDetails,\n bool $logErrors,\n bool $logErrorDetails,\n ?LoggerInterface $logger = null\n ) {\n $this->callableResolver = $callableResolver;\n $this->responseFactory = $responseFactory;\n $this->displayErrorDetails = $displayErrorDetails;\n $this->logErrors = $logErrors;\n $this->logErrorDetails = $logErrorDetails;\n $this->logger = $logger;\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":74,"symbol":"process","kind":"method","lang":"php","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n try {\n return $handler->handle($request);\n } catch (Throwable $e) {\n return $this->handleException($request, $e);\n }\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":83,"symbol":"handleException","kind":"method","lang":"php","code":"public function handleException(ServerRequestInterface $request, Throwable $exception): ResponseInterface\n {\n if ($exception instanceof HttpException) {\n $request = $exception->getRequest();\n }\n\n $exceptionType = get_class($exception);\n $handler = $this->getErrorHandler($exceptionType);\n\n /** @var ResponseInterface */\n return $handler($request, $exception, $this->displayErrorDetails, $this->logErrors, $this->logErrorDetails);\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":103,"symbol":"getErrorHandler","kind":"method","lang":"php","doc":"Get callable to handle scenarios where an error occurs when processing the current request. @param string $type Exception/Throwable name. ie: RuntimeException::class @return callable|ErrorHandler","code":"public function getErrorHandler(string $type)\n {\n if (isset($this->handlers[$type])) {\n return $this->callableResolver->resolve($this->handlers[$type]);\n }\n\n if (isset($this->subClassHandlers[$type])) {\n return $this->callableResolver->resolve($this->subClassHandlers[$type]);\n }\n\n foreach ($this->subClassHandlers as $class => $handler) {\n if (is_subclass_of($type, $class)) {\n return $this->callableResolver->resolve($handler);\n }\n }\n\n return $this->getDefaultErrorHandler();\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":127,"symbol":"getDefaultErrorHandler","kind":"method","lang":"php","doc":"Get default error handler @return ErrorHandler|callable","code":"public function getDefaultErrorHandler()\n {\n if ($this->defaultErrorHandler === null) {\n $this->defaultErrorHandler = new ErrorHandler(\n $this->callableResolver,\n $this->responseFactory,\n $this->logger\n );\n }\n\n return $this->callableResolver->resolve($this->defaultErrorHandler);\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":158,"symbol":"setDefaultErrorHandler","kind":"method","lang":"php","doc":"5. Boolean $logErrorDetails The callable MUST return an instance of \\Psr\\Http\\Message\\ResponseInterface.","code":"public function setDefaultErrorHandler($handler): self\n {\n $this->defaultErrorHandler = $handler;\n return $this;\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":190,"symbol":"setErrorHandler","kind":"method","lang":"php","doc":"5. Boolean $logErrorDetails The callable MUST return an instance of \\Psr\\Http\\Message\\ResponseInterface.","code":"public function setErrorHandler($typeOrTypes, $handler, bool $handleSubclasses = false): self\n {\n if (is_array($typeOrTypes)) {\n foreach ($typeOrTypes as $type) {\n $this->addErrorHandler($type, $handler, $handleSubclasses);\n }\n } else {\n $this->addErrorHandler($typeOrTypes, $handler, $handleSubclasses);\n }\n\n return $this;\n }"} {"repo":"slim","file":"Slim/Middleware/ErrorMiddleware.php","line":207,"symbol":"addErrorHandler","kind":"method","lang":"php","doc":"Used internally to avoid code repetition when passing multiple exceptions to setErrorHandler(). @param string|callable|ErrorHandlerInterface $handler","code":"private function addErrorHandler(string $type, $handler, bool $handleSubclasses): void\n {\n if ($handleSubclasses) {\n $this->subClassHandlers[$type] = $handler;\n } else {\n $this->handlers[$type] = $handler;\n }\n }"} {"repo":"slim","file":"Slim/Middleware/MethodOverrideMiddleware.php","line":22,"symbol":"MethodOverrideMiddleware","kind":"class","lang":"php","doc":"@api","code":"class MethodOverrideMiddleware implements MiddlewareInterface\n{\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $methodHeader = $request->getHeaderLine('X-Http-Method-Override');\n\n if ($methodHeader) {\n $request = $request->withMethod($methodHeader);\n } elseif (strtoupper($request->getMethod()) === 'POST') {\n $body = $request->getParsedBody();\n\n if (is_array($body) && !empty($body['_METHOD']) && is_string($body['_METHOD'])) {\n $request = $request->withMethod($body['_METHOD']);\n }\n\n if ($request->getBody()->eof()) {\n $request->getBody()->rewind();\n }\n }\n\n return $handler->handle($request);\n }\n}"} {"repo":"slim","file":"Slim/Middleware/MethodOverrideMiddleware.php","line":24,"symbol":"process","kind":"method","lang":"php","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $methodHeader = $request->getHeaderLine('X-Http-Method-Override');\n\n if ($methodHeader) {\n $request = $request->withMethod($methodHeader);\n } elseif (strtoupper($request->getMethod()) === 'POST') {\n $body = $request->getParsedBody();\n\n if (is_array($body) && !empty($body['_METHOD']) && is_string($body['_METHOD'])) {\n $request = $request->withMethod($body['_METHOD']);\n }\n\n if ($request->getBody()->eof()) {\n $request->getBody()->rewind();\n }\n }\n\n return $handler->handle($request);\n }"} {"repo":"slim","file":"Slim/Middleware/OutputBufferingMiddleware.php","line":27,"symbol":"OutputBufferingMiddleware","kind":"class","lang":"php","doc":"@api","code":"class OutputBufferingMiddleware implements MiddlewareInterface\n{\n public const APPEND = 'append';\n public const PREPEND = 'prepend';\n\n protected StreamFactoryInterface $streamFactory;\n\n protected string $style;\n\n /**\n * @param string $style Either \"append\" or \"prepend\"\n */\n public function __construct(StreamFactoryInterface $streamFactory, string $style = 'append')\n {\n $this->streamFactory = $streamFactory;\n $this->style = $style;\n\n if (!in_array($style, [static::APPEND, static::PREPEND], true)) {\n throw new InvalidArgumentException(\"Invalid style `{$style}`. Must be `append` or `prepend`\");\n }\n }\n\n /**\n * @throws Throwable\n */\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n try {\n ob_start();\n $response = $handler->handle($request);\n $output = ob_get_clean();\n } catch (Throwable $e) {\n ob_end_clean();\n throw $e;\n }\n\n if (!empty($output)) {\n if ($this->style === static::PREPEND) {\n $body = $this->streamFactory->createStrea"} {"repo":"slim","file":"Slim/Middleware/OutputBufferingMiddleware.php","line":39,"symbol":"__construct","kind":"method","lang":"php","doc":"@param string $style Either \"append\" or \"prepend\"","code":"public function __construct(StreamFactoryInterface $streamFactory, string $style = 'append')\n {\n $this->streamFactory = $streamFactory;\n $this->style = $style;\n\n if (!in_array($style, [static::APPEND, static::PREPEND], true)) {\n throw new InvalidArgumentException(\"Invalid style `{$style}`. Must be `append` or `prepend`\");\n }\n }"} {"repo":"slim","file":"Slim/Middleware/OutputBufferingMiddleware.php","line":52,"symbol":"process","kind":"method","lang":"php","doc":"@throws Throwable","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n try {\n ob_start();\n $response = $handler->handle($request);\n $output = ob_get_clean();\n } catch (Throwable $e) {\n ob_end_clean();\n throw $e;\n }\n\n if (!empty($output)) {\n if ($this->style === static::PREPEND) {\n $body = $this->streamFactory->createStream();\n $body->write($output . $response->getBody());\n $response = $response->withBody($body);\n } elseif ($this->style === static::APPEND && $response->getBody()->isWritable()) {\n $response->getBody()->write($output);\n }\n }\n\n return $response;\n }"} {"repo":"slim","file":"Slim/Middleware/RoutingMiddleware.php","line":25,"symbol":"RoutingMiddleware","kind":"class","lang":"php","code":"class RoutingMiddleware implements MiddlewareInterface\n{\n protected RouteResolverInterface $routeResolver;\n\n protected RouteParserInterface $routeParser;\n\n public function __construct(RouteResolverInterface $routeResolver, RouteParserInterface $routeParser)\n {\n $this->routeResolver = $routeResolver;\n $this->routeParser = $routeParser;\n }\n\n /**\n * @throws HttpNotFoundException\n * @throws HttpMethodNotAllowedException\n * @throws RuntimeException\n */\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $request = $this->performRouting($request);\n return $handler->handle($request);\n }\n\n /**\n * Perform routing\n *\n * @param ServerRequestInterface $request PSR7 Server Request\n *\n * @throws HttpNotFoundException\n * @throws HttpMethodNotAllowedException\n * @throws RuntimeException\n */\n public function performRouting(ServerRequestInterface $request): ServerRequestInterface\n {\n $request = $request->withAttribute(RouteContext::ROUTE_PARSER, $this->routeParser);\n\n $routingResults = $this->resolveRoutingResult"} {"repo":"slim","file":"Slim/Middleware/RoutingMiddleware.php","line":31,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(RouteResolverInterface $routeResolver, RouteParserInterface $routeParser)\n {\n $this->routeResolver = $routeResolver;\n $this->routeParser = $routeParser;\n }"} {"repo":"slim","file":"Slim/Middleware/RoutingMiddleware.php","line":42,"symbol":"process","kind":"method","lang":"php","doc":"@throws HttpNotFoundException @throws HttpMethodNotAllowedException @throws RuntimeException","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $request = $this->performRouting($request);\n return $handler->handle($request);\n }"} {"repo":"slim","file":"Slim/Middleware/RoutingMiddleware.php","line":57,"symbol":"performRouting","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request PSR7 Server Request @throws HttpNotFoundException @throws HttpMethodNotAllowedException @throws RuntimeException","code":"public function performRouting(ServerRequestInterface $request): ServerRequestInterface\n {\n $request = $request->withAttribute(RouteContext::ROUTE_PARSER, $this->routeParser);\n\n $routingResults = $this->resolveRoutingResultsFromRequest($request);\n $routeStatus = $routingResults->getRouteStatus();\n\n $request = $request->withAttribute(RouteContext::ROUTING_RESULTS, $routingResults);\n\n switch ($routeStatus) {\n case RoutingResults::FOUND:\n $routeArguments = $routingResults->getRouteArguments();\n $routeIdentifier = $routingResults->getRouteIdentifier() ?? '';\n $route = $this->routeResolver\n ->resolveRoute($routeIdentifier)\n ->prepare($routeArguments);\n return $request->withAttribute(RouteContext::ROUTE, $route);\n\n case RoutingResults::NOT_FOUND:\n throw new HttpNotFoundException($request);\n\n case RoutingResults::METHOD_NOT_ALLOWED:\n $exception = new HttpMethodNotAllowedException($request);\n $exception->setAllowedMethods($routingResults->getAllowedMethods());\n thr"} {"repo":"slim","file":"Slim/Middleware/RoutingMiddleware.php","line":91,"symbol":"resolveRoutingResultsFromRequest","kind":"method","lang":"php","doc":"Resolves the route from the given request","code":"protected function resolveRoutingResultsFromRequest(ServerRequestInterface $request): RoutingResults\n {\n return $this->routeResolver->computeRoutingResults(\n $request->getUri()->getPath(),\n $request->getMethod()\n );\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":35,"symbol":"MiddlewareDispatcher","kind":"class","lang":"php","doc":"@api @template TContainerInterface of (ContainerInterface|null)","code":"class MiddlewareDispatcher implements MiddlewareDispatcherInterface\n{\n /**\n * Tip of the middleware call stack\n */\n protected RequestHandlerInterface $tip;\n\n protected ?CallableResolverInterface $callableResolver;\n\n /** @var TContainerInterface $container */\n protected ?ContainerInterface $container;\n\n /**\n * @param TContainerInterface $container\n */\n public function __construct(\n RequestHandlerInterface $kernel,\n ?CallableResolverInterface $callableResolver = null,\n ?ContainerInterface $container = null\n ) {\n $this->seedMiddlewareStack($kernel);\n $this->callableResolver = $callableResolver;\n $this->container = $container;\n }\n\n /**\n * {@inheritdoc}\n */\n public function seedMiddlewareStack(RequestHandlerInterface $kernel): void\n {\n $this->tip = $kernel;\n }\n\n /**\n * Invoke the middleware stack\n */\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n return $this->tip->handle($request);\n }\n\n /**\n * Add a new middleware to the stack\n *\n * Middleware are organized as a stack. That means middleware\n * that"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":50,"symbol":"__construct","kind":"method","lang":"php","doc":"@param TContainerInterface $container","code":"public function __construct(\n RequestHandlerInterface $kernel,\n ?CallableResolverInterface $callableResolver = null,\n ?ContainerInterface $container = null\n ) {\n $this->seedMiddlewareStack($kernel);\n $this->callableResolver = $callableResolver;\n $this->container = $container;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":63,"symbol":"seedMiddlewareStack","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function seedMiddlewareStack(RequestHandlerInterface $kernel): void\n {\n $this->tip = $kernel;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":71,"symbol":"handle","kind":"method","lang":"php","doc":"Invoke the middleware stack","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n return $this->tip->handle($request);\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":85,"symbol":"add","kind":"method","lang":"php","doc":"Middleware are organized as a stack. That means middleware that have been added before will be executed after the newly added one (last in, first out). @param MiddlewareInterface|string|callable $middleware","code":"public function add($middleware): MiddlewareDispatcherInterface\n {\n if ($middleware instanceof MiddlewareInterface) {\n return $this->addMiddleware($middleware);\n }\n\n if (is_string($middleware)) {\n return $this->addDeferred($middleware);\n }\n\n if (is_callable($middleware)) {\n return $this->addCallable($middleware);\n }\n\n /** @phpstan-ignore-next-line */\n throw new RuntimeException(\n 'A middleware must be an object/class name referencing an implementation of ' .\n 'MiddlewareInterface or a callable with a matching signature.'\n );\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":113,"symbol":"addMiddleware","kind":"method","lang":"php","doc":"Add a new middleware to the stack Middleware are organized as a stack. That means middleware that have been added before will be executed after the newly added one (last in, first out).","code":"public function addMiddleware(MiddlewareInterface $middleware): MiddlewareDispatcherInterface\n {\n $next = $this->tip;\n $this->tip = new class ($middleware, $next) implements RequestHandlerInterface {\n private MiddlewareInterface $middleware;\n\n private RequestHandlerInterface $next;\n\n public function __construct(MiddlewareInterface $middleware, RequestHandlerInterface $next)\n {\n $this->middleware = $middleware;\n $this->next = $next;\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n return $this->middleware->process($request, $this->next);\n }\n };\n\n return $this;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":121,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(MiddlewareInterface $middleware, RequestHandlerInterface $next)\n {\n $this->middleware = $middleware;\n $this->next = $next;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":127,"symbol":"handle","kind":"method","lang":"php","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n return $this->middleware->process($request, $this->next);\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":144,"symbol":"addDeferred","kind":"method","lang":"php","doc":"Middleware are organized as a stack. That means middleware that have been added before will be executed after the newly added one (last in, first out). @return MiddlewareDispatcher","code":"public function addDeferred(string $middleware): self\n {\n $next = $this->tip;\n $this->tip = new class (\n $middleware,\n $next,\n $this->container,\n $this->callableResolver\n ) implements RequestHandlerInterface {\n private string $middleware;\n\n private RequestHandlerInterface $next;\n\n private ?ContainerInterface $container;\n\n private ?CallableResolverInterface $callableResolver;\n\n public function __construct(\n string $middleware,\n RequestHandlerInterface $next,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null\n ) {\n $this->middleware = $middleware;\n $this->next = $next;\n $this->container = $container;\n $this->callableResolver = $callableResolver;\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n if ($this->callableResolver instanceof AdvancedCallableResolverInterface) {\n $callable = $this->calla"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":161,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(\n string $middleware,\n RequestHandlerInterface $next,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null\n ) {\n $this->middleware = $middleware;\n $this->next = $next;\n $this->container = $container;\n $this->callableResolver = $callableResolver;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":173,"symbol":"handle","kind":"method","lang":"php","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n if ($this->callableResolver instanceof AdvancedCallableResolverInterface) {\n $callable = $this->callableResolver->resolveMiddleware($this->middleware);\n /** @var ResponseInterface */\n return $callable($request, $this->next);\n }\n\n $callable = null;\n\n if ($this->callableResolver instanceof CallableResolverInterface) {\n try {\n $callable = $this->callableResolver->resolve($this->middleware);\n } catch (RuntimeException $e) {\n // Do Nothing\n }\n }\n\n if (!$callable) {\n $resolved = $this->middleware;\n $instance = null;\n $method = null;\n\n /** @psalm-suppress ArgumentTypeCoercion */\n // Check for Slim callable as `class:method`\n if (preg_match(CallableResolver::$callablePattern, $resolved, $matches)) {\n $resolved = $matches["} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":254,"symbol":"addCallable","kind":"method","lang":"php","doc":"Middleware are organized as a stack. That means middleware that have been added before will be executed after the newly added one (last in, first out). @return MiddlewareDispatcher","code":"public function addCallable(callable $middleware): self\n {\n $next = $this->tip;\n\n if ($this->container && $middleware instanceof Closure) {\n /** @var Closure $middleware */\n $middleware = $middleware->bindTo($this->container);\n }\n\n $this->tip = new class ($middleware, $next) implements RequestHandlerInterface {\n /**\n * @var callable\n */\n private $middleware;\n\n /**\n * @var RequestHandlerInterface\n */\n private $next;\n\n public function __construct(callable $middleware, RequestHandlerInterface $next)\n {\n $this->middleware = $middleware;\n $this->next = $next;\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n /** @var ResponseInterface */\n return ($this->middleware)($request, $this->next);\n }\n };\n\n return $this;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":274,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(callable $middleware, RequestHandlerInterface $next)\n {\n $this->middleware = $middleware;\n $this->next = $next;\n }"} {"repo":"slim","file":"Slim/MiddlewareDispatcher.php","line":280,"symbol":"handle","kind":"method","lang":"php","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n /** @var ResponseInterface */\n return ($this->middleware)($request, $this->next);\n }"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":26,"symbol":"ResponseEmitter","kind":"class","lang":"php","code":"class ResponseEmitter\n{\n private int $responseChunkSize;\n\n public function __construct(int $responseChunkSize = 4096)\n {\n $this->responseChunkSize = $responseChunkSize;\n }\n\n /**\n * Send the response the client\n */\n public function emit(ResponseInterface $response): void\n {\n $isEmpty = $this->isResponseEmpty($response);\n if (headers_sent() === false) {\n $this->emitHeaders($response);\n\n // Set the status _after_ the headers, because of PHP's \"helpful\" behavior with location headers.\n // See https://github.com/slimphp/Slim/issues/1730\n\n $this->emitStatusLine($response);\n }\n\n if (!$isEmpty) {\n $this->emitBody($response);\n }\n }\n\n /**\n * Emit Response Headers\n */\n private function emitHeaders(ResponseInterface $response): void\n {\n foreach ($response->getHeaders() as $name => $values) {\n $first = strtolower($name) !== 'set-cookie';\n foreach ($values as $value) {\n $header = sprintf('%s: %s', $name, $value);\n header($header, $first);\n $first = false;\n }\n }\n"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":30,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(int $responseChunkSize = 4096)\n {\n $this->responseChunkSize = $responseChunkSize;\n }"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":38,"symbol":"emit","kind":"method","lang":"php","doc":"Send the response the client","code":"public function emit(ResponseInterface $response): void\n {\n $isEmpty = $this->isResponseEmpty($response);\n if (headers_sent() === false) {\n $this->emitHeaders($response);\n\n // Set the status _after_ the headers, because of PHP's \"helpful\" behavior with location headers.\n // See https://github.com/slimphp/Slim/issues/1730\n\n $this->emitStatusLine($response);\n }\n\n if (!$isEmpty) {\n $this->emitBody($response);\n }\n }"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":58,"symbol":"emitHeaders","kind":"method","lang":"php","doc":"Emit Response Headers","code":"private function emitHeaders(ResponseInterface $response): void\n {\n foreach ($response->getHeaders() as $name => $values) {\n $first = strtolower($name) !== 'set-cookie';\n foreach ($values as $value) {\n $header = sprintf('%s: %s', $name, $value);\n header($header, $first);\n $first = false;\n }\n }\n }"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":73,"symbol":"emitStatusLine","kind":"method","lang":"php","doc":"Emit Status Line","code":"private function emitStatusLine(ResponseInterface $response): void\n {\n $statusLine = sprintf(\n 'HTTP/%s %s %s',\n $response->getProtocolVersion(),\n $response->getStatusCode(),\n $response->getReasonPhrase()\n );\n header($statusLine, true, $response->getStatusCode());\n }"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":87,"symbol":"emitBody","kind":"method","lang":"php","doc":"Emit Body","code":"private function emitBody(ResponseInterface $response): void\n {\n $body = $response->getBody();\n if ($body->isSeekable()) {\n $body->rewind();\n }\n\n $amountToRead = (int) $response->getHeaderLine('Content-Length');\n if (!$amountToRead) {\n $amountToRead = $body->getSize();\n }\n\n if ($amountToRead) {\n while ($amountToRead > 0 && !$body->eof()) {\n $length = min($this->responseChunkSize, $amountToRead);\n $data = $body->read($length);\n echo $data;\n\n $amountToRead -= strlen($data);\n\n if (connection_status() !== CONNECTION_NORMAL) {\n break;\n }\n }\n } else {\n while (!$body->eof()) {\n echo $body->read($this->responseChunkSize);\n if (connection_status() !== CONNECTION_NORMAL) {\n break;\n }\n }\n }\n }"} {"repo":"slim","file":"Slim/ResponseEmitter.php","line":124,"symbol":"isResponseEmpty","kind":"method","lang":"php","doc":"Asserts response body is empty or status code is 204, 205 or 304","code":"public function isResponseEmpty(ResponseInterface $response): bool\n {\n if (in_array($response->getStatusCode(), [204, 205, 304], true)) {\n return true;\n }\n $stream = $response->getBody();\n $seekable = $stream->isSeekable();\n if ($seekable) {\n $stream->rewind();\n }\n return $seekable ? $stream->read(1) === '' : $stream->eof();\n }"} {"repo":"slim","file":"Slim/Routing/Dispatcher.php","line":13,"symbol":"Dispatcher","kind":"class","lang":"php","code":"class Dispatcher implements DispatcherInterface\n{\n private RouteCollectorInterface $routeCollector;\n\n private ?FastRouteDispatcher $dispatcher = null;\n\n public function __construct(RouteCollectorInterface $routeCollector)\n {\n $this->routeCollector = $routeCollector;\n }\n\n protected function createDispatcher(): FastRouteDispatcher\n {\n if ($this->dispatcher) {\n return $this->dispatcher;\n }\n\n $routeDefinitionCallback = function (FastRouteCollector $r): void {\n $basePath = $this->routeCollector->getBasePath();\n\n foreach ($this->routeCollector->getRoutes() as $route) {\n $r->addRoute($route->getMethods(), $basePath . $route->getPattern(), $route->getIdentifier());\n }\n };\n\n $cacheFile = $this->routeCollector->getCacheFile();\n if ($cacheFile) {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = \\FastRoute\\cachedDispatcher($routeDefinitionCallback, [\n 'dataGenerator' => GroupCountBased::class,\n 'dispatcher' => FastRouteDispatcher::class,\n 'routeParser' => new Std(),\n 'cacheFi"} {"repo":"slim","file":"Slim/Routing/Dispatcher.php","line":19,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(RouteCollectorInterface $routeCollector)\n {\n $this->routeCollector = $routeCollector;\n }"} {"repo":"slim","file":"Slim/Routing/Dispatcher.php","line":24,"symbol":"createDispatcher","kind":"method","lang":"php","code":"protected function createDispatcher(): FastRouteDispatcher\n {\n if ($this->dispatcher) {\n return $this->dispatcher;\n }\n\n $routeDefinitionCallback = function (FastRouteCollector $r): void {\n $basePath = $this->routeCollector->getBasePath();\n\n foreach ($this->routeCollector->getRoutes() as $route) {\n $r->addRoute($route->getMethods(), $basePath . $route->getPattern(), $route->getIdentifier());\n }\n };\n\n $cacheFile = $this->routeCollector->getCacheFile();\n if ($cacheFile) {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = \\FastRoute\\cachedDispatcher($routeDefinitionCallback, [\n 'dataGenerator' => GroupCountBased::class,\n 'dispatcher' => FastRouteDispatcher::class,\n 'routeParser' => new Std(),\n 'cacheFile' => $cacheFile,\n ]);\n } else {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = \\FastRoute\\simpleDispatcher($routeDefinitionCallback, [\n 'dataGenerator' => GroupCountBased::class,\n 'dispatcher' => FastRouteDispatc"} {"repo":"slim","file":"Slim/Routing/Dispatcher.php","line":63,"symbol":"dispatch","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function dispatch(string $method, string $uri): RoutingResults\n {\n $dispatcher = $this->createDispatcher();\n $results = $dispatcher->dispatch($method, $uri);\n return new RoutingResults($this, $method, $uri, $results[0], $results[1], $results[2]);\n }"} {"repo":"slim","file":"Slim/Routing/Dispatcher.php","line":73,"symbol":"getAllowedMethods","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getAllowedMethods(string $uri): array\n {\n $dispatcher = $this->createDispatcher();\n return $dispatcher->getAllowedMethods($uri);\n }"} {"repo":"slim","file":"Slim/Routing/FastRouteDispatcher.php","line":15,"symbol":"FastRouteDispatcher","kind":"class","lang":"php","code":"class FastRouteDispatcher extends GroupCountBased\n{\n /**\n * @var string|null\n */\n private ?string $allowedMethodsUri = null;\n\n /**\n * @var string[]\n */\n private array $allowedMethods = [];\n\n /**\n * @param string $httpMethod\n * @param string $uri\n *\n * @return array{int, string|null, array}\n */\n public function dispatch($httpMethod, $uri): array\n {\n $routingResults = $this->routingResults($httpMethod, $uri);\n if ($routingResults[0] === self::FOUND) {\n return $routingResults;\n }\n\n // For HEAD requests, attempt fallback to GET\n if ($httpMethod === 'HEAD') {\n $routingResults = $this->routingResults('GET', $uri);\n if ($routingResults[0] === self::FOUND) {\n return $routingResults;\n }\n }\n\n // If nothing else matches, try fallback routes\n $routingResults = $this->routingResults('*', $uri);\n if ($routingResults[0] === self::FOUND) {\n return $routingResults;\n }\n\n if (!empty($this->getAllowedMethods($uri))) {\n return [self::METHOD_NOT_ALLOWED, null, []];\n }\n\n"} {"repo":"slim","file":"Slim/Routing/FastRouteDispatcher.php","line":33,"symbol":"dispatch","kind":"method","lang":"php","doc":"@param string $httpMethod @param string $uri @return array{int, string|null, array}","code":"public function dispatch($httpMethod, $uri): array\n {\n $routingResults = $this->routingResults($httpMethod, $uri);\n if ($routingResults[0] === self::FOUND) {\n return $routingResults;\n }\n\n // For HEAD requests, attempt fallback to GET\n if ($httpMethod === 'HEAD') {\n $routingResults = $this->routingResults('GET', $uri);\n if ($routingResults[0] === self::FOUND) {\n return $routingResults;\n }\n }\n\n // If nothing else matches, try fallback routes\n $routingResults = $this->routingResults('*', $uri);\n if ($routingResults[0] === self::FOUND) {\n return $routingResults;\n }\n\n if (!empty($this->getAllowedMethods($uri))) {\n return [self::METHOD_NOT_ALLOWED, null, []];\n }\n\n return [self::NOT_FOUND, null, []];\n }"} {"repo":"slim","file":"Slim/Routing/FastRouteDispatcher.php","line":67,"symbol":"routingResults","kind":"method","lang":"php","doc":"@param string $httpMethod @param string $uri @return array{int, string|null, array}","code":"private function routingResults(string $httpMethod, string $uri): array\n {\n if (isset($this->staticRouteMap[$httpMethod][$uri])) {\n /** @var string $routeIdentifier */\n $routeIdentifier = $this->staticRouteMap[$httpMethod][$uri];\n return [self::FOUND, $routeIdentifier, []];\n }\n\n if (isset($this->variableRouteData[$httpMethod])) {\n /** @var array{0: int, 1?: string, 2?: array} $result */\n $result = $this->dispatchVariableRoute($this->variableRouteData[$httpMethod], $uri);\n if ($result[0] === self::FOUND) {\n /** @var array{int, string, array} $result */\n return [self::FOUND, $result[1], $result[2]];\n }\n }\n\n return [self::NOT_FOUND, null, []];\n }"} {"repo":"slim","file":"Slim/Routing/FastRouteDispatcher.php","line":92,"symbol":"getAllowedMethods","kind":"method","lang":"php","doc":"@param string $uri @return string[]","code":"public function getAllowedMethods(string $uri): array\n {\n if ($this->allowedMethodsUri === $uri) {\n return $this->allowedMethods;\n }\n\n $allowedMethods = [];\n foreach ($this->staticRouteMap as $method => $uriMap) {\n if (isset($uriMap[$uri])) {\n $allowedMethods[$method] = true;\n }\n }\n\n foreach ($this->variableRouteData as $method => $routeData) {\n $result = $this->dispatchVariableRoute($routeData, $uri);\n if ($result[0] === self::FOUND) {\n $allowedMethods[$method] = true;\n }\n }\n\n $this->allowedMethodsUri = $uri;\n\n return $this->allowedMethods = array_keys($allowedMethods);\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":40,"symbol":"Route","kind":"class","lang":"php","doc":"@api @template TContainerInterface of (ContainerInterface|null)","code":"class Route implements RouteInterface, RequestHandlerInterface\n{\n /**\n * HTTP methods supported by this route\n *\n * @var string[]\n */\n protected array $methods = [];\n\n /**\n * Route identifier\n */\n protected string $identifier;\n\n /**\n * Route name\n */\n protected ?string $name = null;\n\n /**\n * Parent route groups\n *\n * @var RouteGroupInterface[]\n */\n protected array $groups;\n\n protected InvocationStrategyInterface $invocationStrategy;\n\n /**\n * Route parameters\n *\n * @var array\n */\n protected array $arguments = [];\n\n /**\n * Route arguments parameters\n *\n * @var array\n */\n protected array $savedArguments = [];\n\n /**\n * Container\n * @var TContainerInterface $container\n */\n protected ?ContainerInterface $container = null;\n\n /** @var MiddlewareDispatcher $middlewareDispatcher */\n protected MiddlewareDispatcher $middlewareDispatcher;\n\n /**\n * Route callable\n *\n * @var callable|array{class-string, string}|string\n */\n protected $callable;\n\n protected CallableResolverInterfac"} {"repo":"slim","file":"Slim/Routing/Route.php","line":120,"symbol":"__construct","kind":"method","lang":"php","doc":"@param CallableResolverInterface $callableResolver @param TContainerInterface $container @param InvocationStrategyInterface|null $invocationStrategy @param RouteGroupInterface[] $groups The parent route groups @param int $identifier The route identifier","code":"public function __construct(\n array $methods,\n string $pattern,\n $callable,\n ResponseFactoryInterface $responseFactory,\n CallableResolverInterface $callableResolver,\n ?ContainerInterface $container = null,\n ?InvocationStrategyInterface $invocationStrategy = null,\n array $groups = [],\n int $identifier = 0\n ) {\n $this->methods = $methods;\n $this->pattern = $pattern;\n $this->callable = $callable;\n $this->responseFactory = $responseFactory;\n $this->callableResolver = $callableResolver;\n $this->container = $container;\n $this->invocationStrategy = $invocationStrategy ?? new RequestResponse();\n $this->groups = $groups;\n $this->identifier = 'route' . $identifier;\n $this->middlewareDispatcher = new MiddlewareDispatcher($this, $callableResolver, $container);\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":143,"symbol":"getCallableResolver","kind":"method","lang":"php","code":"public function getCallableResolver(): CallableResolverInterface\n {\n return $this->callableResolver;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":151,"symbol":"getInvocationStrategy","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getInvocationStrategy(): InvocationStrategyInterface\n {\n return $this->invocationStrategy;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":159,"symbol":"setInvocationStrategy","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setInvocationStrategy(InvocationStrategyInterface $invocationStrategy): RouteInterface\n {\n $this->invocationStrategy = $invocationStrategy;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":168,"symbol":"getMethods","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getMethods(): array\n {\n return $this->methods;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":176,"symbol":"getPattern","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getPattern(): string\n {\n return $this->pattern;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":184,"symbol":"setPattern","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setPattern(string $pattern): RouteInterface\n {\n $this->pattern = $pattern;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":193,"symbol":"getCallable","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getCallable()\n {\n return $this->callable;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":201,"symbol":"setCallable","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setCallable($callable): RouteInterface\n {\n $this->callable = $callable;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":210,"symbol":"getName","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getName(): ?string\n {\n return $this->name;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":218,"symbol":"setName","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setName(string $name): RouteInterface\n {\n $this->name = $name;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":227,"symbol":"getIdentifier","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getIdentifier(): string\n {\n return $this->identifier;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":235,"symbol":"getArgument","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getArgument(string $name, ?string $default = null): ?string\n {\n if (array_key_exists($name, $this->arguments)) {\n return $this->arguments[$name];\n }\n return $default;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":246,"symbol":"getArguments","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getArguments(): array\n {\n return $this->arguments;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":254,"symbol":"setArguments","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setArguments(array $arguments, bool $includeInSavedArguments = true): RouteInterface\n {\n if ($includeInSavedArguments) {\n $this->savedArguments = $arguments;\n }\n\n $this->arguments = $arguments;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":267,"symbol":"getGroups","kind":"method","lang":"php","doc":"@return RouteGroupInterface[]","code":"public function getGroups(): array\n {\n return $this->groups;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":275,"symbol":"add","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function add($middleware): RouteInterface\n {\n $this->middlewareDispatcher->add($middleware);\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":284,"symbol":"addMiddleware","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function addMiddleware(MiddlewareInterface $middleware): RouteInterface\n {\n $this->middlewareDispatcher->addMiddleware($middleware);\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":293,"symbol":"prepare","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function prepare(array $arguments): RouteInterface\n {\n $this->arguments = array_replace($this->savedArguments, $arguments);\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":302,"symbol":"setArgument","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setArgument(string $name, string $value, bool $includeInSavedArguments = true): RouteInterface\n {\n if ($includeInSavedArguments) {\n $this->savedArguments[$name] = $value;\n }\n\n $this->arguments[$name] = $value;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":315,"symbol":"run","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function run(ServerRequestInterface $request): ResponseInterface\n {\n if (!$this->groupMiddlewareAppended) {\n $this->appendGroupMiddlewareToRoute();\n }\n\n return $this->middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":327,"symbol":"appendGroupMiddlewareToRoute","kind":"method","lang":"php","doc":"@return void","code":"protected function appendGroupMiddlewareToRoute(): void\n {\n $inner = $this->middlewareDispatcher;\n $this->middlewareDispatcher = new MiddlewareDispatcher($inner, $this->callableResolver, $this->container);\n\n foreach (array_reverse($this->groups) as $group) {\n $group->appendMiddlewareToDispatcher($this->middlewareDispatcher);\n }\n\n $this->groupMiddlewareAppended = true;\n }"} {"repo":"slim","file":"Slim/Routing/Route.php","line":342,"symbol":"handle","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n if ($this->callableResolver instanceof AdvancedCallableResolverInterface) {\n $callable = $this->callableResolver->resolveRoute($this->callable);\n } else {\n $callable = $this->callableResolver->resolve($this->callable);\n }\n $strategy = $this->invocationStrategy;\n\n $strategyImplements = class_implements($strategy);\n\n if (\n is_array($callable)\n && $callable[0] instanceof RequestHandlerInterface\n && !in_array(RequestHandlerInvocationStrategyInterface::class, $strategyImplements)\n ) {\n $strategy = new RequestHandler();\n }\n\n $response = $this->responseFactory->createResponse();\n return $strategy($callable, $request, $response, $this->arguments);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":37,"symbol":"RouteCollector","kind":"class","lang":"php","doc":"RouteCollector is used to collect routes and route groups as well as generate paths and URLs relative to its environment @template TContainerInterface of (ContainerInterface|null)","code":"class RouteCollector implements RouteCollectorInterface\n{\n protected RouteParserInterface $routeParser;\n\n protected CallableResolverInterface $callableResolver;\n\n protected ?ContainerInterface $container = null;\n\n protected InvocationStrategyInterface $defaultInvocationStrategy;\n\n /**\n * Base path used in pathFor()\n */\n protected string $basePath = '';\n\n /**\n * Path to fast route cache file. Set to null to disable route caching\n */\n protected ?string $cacheFile = null;\n\n /**\n * Routes\n *\n * @var RouteInterface[]\n */\n protected array $routes = [];\n\n /**\n * Routes indexed by name\n *\n * @var RouteInterface[]\n */\n protected array $routesByName = [];\n\n /**\n * Route groups\n *\n * @var RouteGroupInterface[]\n */\n protected array $routeGroups = [];\n\n /**\n * Route counter incrementer\n */\n protected int $routeCounter = 0;\n\n protected ResponseFactoryInterface $responseFactory;\n\n /**\n * @param TContainerInterface $container\n */\n public function __construct(\n ResponseFactoryInterface $responseFactory,\n CallableResolverInterface $callableResolver,\n "} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":88,"symbol":"__construct","kind":"method","lang":"php","doc":"@param TContainerInterface $container","code":"public function __construct(\n ResponseFactoryInterface $responseFactory,\n CallableResolverInterface $callableResolver,\n ?ContainerInterface $container = null,\n ?InvocationStrategyInterface $defaultInvocationStrategy = null,\n ?RouteParserInterface $routeParser = null,\n ?string $cacheFile = null\n ) {\n $this->responseFactory = $responseFactory;\n $this->callableResolver = $callableResolver;\n $this->container = $container;\n $this->defaultInvocationStrategy = $defaultInvocationStrategy ?? new RequestResponse();\n $this->routeParser = $routeParser ?? new RouteParser($this);\n\n if ($cacheFile) {\n $this->setCacheFile($cacheFile);\n }\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":107,"symbol":"getRouteParser","kind":"method","lang":"php","code":"public function getRouteParser(): RouteParserInterface\n {\n return $this->routeParser;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":115,"symbol":"getDefaultInvocationStrategy","kind":"method","lang":"php","doc":"Get default route invocation strategy","code":"public function getDefaultInvocationStrategy(): InvocationStrategyInterface\n {\n return $this->defaultInvocationStrategy;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":120,"symbol":"setDefaultInvocationStrategy","kind":"method","lang":"php","code":"public function setDefaultInvocationStrategy(InvocationStrategyInterface $strategy): RouteCollectorInterface\n {\n $this->defaultInvocationStrategy = $strategy;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":129,"symbol":"getCacheFile","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getCacheFile(): ?string\n {\n return $this->cacheFile;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":137,"symbol":"setCacheFile","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setCacheFile(string $cacheFile): RouteCollectorInterface\n {\n if (file_exists($cacheFile) && !is_readable($cacheFile)) {\n throw new RuntimeException(\n sprintf('Route collector cache file `%s` is not readable', $cacheFile)\n );\n }\n\n if (!file_exists($cacheFile) && !is_writable(dirname($cacheFile))) {\n throw new RuntimeException(\n sprintf('Route collector cache file directory `%s` is not writable', dirname($cacheFile))\n );\n }\n\n $this->cacheFile = $cacheFile;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":158,"symbol":"getBasePath","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getBasePath(): string\n {\n return $this->basePath;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":166,"symbol":"setBasePath","kind":"method","lang":"php","doc":"Set the base path used in urlFor()","code":"public function setBasePath(string $basePath): RouteCollectorInterface\n {\n $this->basePath = $basePath;\n\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":176,"symbol":"getRoutes","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getRoutes(): array\n {\n return $this->routes;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":184,"symbol":"removeNamedRoute","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function removeNamedRoute(string $name): RouteCollectorInterface\n {\n $route = $this->getNamedRoute($name);\n\n unset($this->routesByName[$name], $this->routes[$route->getIdentifier()]);\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":195,"symbol":"getNamedRoute","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getNamedRoute(string $name): RouteInterface\n {\n if (isset($this->routesByName[$name])) {\n $route = $this->routesByName[$name];\n if ($route->getName() === $name) {\n return $route;\n }\n\n unset($this->routesByName[$name]);\n }\n\n foreach ($this->routes as $route) {\n if ($name === $route->getName()) {\n $this->routesByName[$name] = $route;\n return $route;\n }\n }\n\n throw new RuntimeException('Named route does not exist for name: ' . $name);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":219,"symbol":"lookupRoute","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function lookupRoute(string $identifier): RouteInterface\n {\n if (!isset($this->routes[$identifier])) {\n throw new RuntimeException('Route not found, looks like your route cache is stale.');\n }\n return $this->routes[$identifier];\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":230,"symbol":"group","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function group(string $pattern, $callable): RouteGroupInterface\n {\n $routeGroup = $this->createGroup($pattern, $callable);\n $this->routeGroups[] = $routeGroup;\n\n $routeGroup->collectRoutes();\n array_pop($this->routeGroups);\n\n return $routeGroup;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":244,"symbol":"createGroup","kind":"method","lang":"php","doc":"@param string|callable $callable","code":"protected function createGroup(string $pattern, $callable): RouteGroupInterface\n {\n $routeCollectorProxy = $this->createProxy($pattern);\n return new RouteGroup($pattern, $callable, $this->callableResolver, $routeCollectorProxy);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":253,"symbol":"createProxy","kind":"method","lang":"php","doc":"@return RouteCollectorProxyInterface","code":"protected function createProxy(string $pattern): RouteCollectorProxyInterface\n {\n /** @var RouteCollectorProxy */\n return new RouteCollectorProxy(\n $this->responseFactory,\n $this->callableResolver,\n $this->container,\n $this,\n $pattern\n );\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":268,"symbol":"map","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function map(array $methods, string $pattern, $handler): RouteInterface\n {\n $route = $this->createRoute($methods, $pattern, $handler);\n $this->routes[$route->getIdentifier()] = $route;\n\n $routeName = $route->getName();\n if ($routeName !== null && !isset($this->routesByName[$routeName])) {\n $this->routesByName[$routeName] = $route;\n }\n\n $this->routeCounter++;\n\n return $route;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollector.php","line":287,"symbol":"createRoute","kind":"method","lang":"php","doc":"@param string[] $methods @param callable|array{class-string, string}|string $callable","code":"protected function createRoute(array $methods, string $pattern, $callable): RouteInterface\n {\n return new Route(\n $methods,\n $pattern,\n $callable,\n $this->responseFactory,\n $this->callableResolver,\n $this->container,\n $this->defaultInvocationStrategy,\n $this->routeGroups,\n $this->routeCounter\n );\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":25,"symbol":"RouteCollectorProxy","kind":"class","lang":"php","doc":"@template TContainerInterface of (ContainerInterface|null) @template-implements RouteCollectorProxyInterface","code":"class RouteCollectorProxy implements RouteCollectorProxyInterface\n{\n protected ResponseFactoryInterface $responseFactory;\n\n protected CallableResolverInterface $callableResolver;\n\n /** @var TContainerInterface */\n protected ?ContainerInterface $container = null;\n\n protected RouteCollectorInterface $routeCollector;\n\n protected string $groupPattern;\n\n /**\n * @param TContainerInterface $container\n */\n public function __construct(\n ResponseFactoryInterface $responseFactory,\n CallableResolverInterface $callableResolver,\n ?ContainerInterface $container = null,\n ?RouteCollectorInterface $routeCollector = null,\n string $groupPattern = ''\n ) {\n $this->responseFactory = $responseFactory;\n $this->callableResolver = $callableResolver;\n $this->container = $container;\n $this->routeCollector = $routeCollector ?? new RouteCollector($responseFactory, $callableResolver, $container);\n $this->groupPattern = $groupPattern;\n }\n\n /**\n * {@inheritdoc}\n */\n public function getResponseFactory(): ResponseFactoryInterface\n {\n return $this->responseFactory;\n }\n\n /**\n * {"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":41,"symbol":"__construct","kind":"method","lang":"php","doc":"@param TContainerInterface $container","code":"public function __construct(\n ResponseFactoryInterface $responseFactory,\n CallableResolverInterface $callableResolver,\n ?ContainerInterface $container = null,\n ?RouteCollectorInterface $routeCollector = null,\n string $groupPattern = ''\n ) {\n $this->responseFactory = $responseFactory;\n $this->callableResolver = $callableResolver;\n $this->container = $container;\n $this->routeCollector = $routeCollector ?? new RouteCollector($responseFactory, $callableResolver, $container);\n $this->groupPattern = $groupPattern;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":58,"symbol":"getResponseFactory","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getResponseFactory(): ResponseFactoryInterface\n {\n return $this->responseFactory;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":66,"symbol":"getCallableResolver","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getCallableResolver(): CallableResolverInterface\n {\n return $this->callableResolver;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":75,"symbol":"getContainer","kind":"method","lang":"php","doc":"{@inheritdoc} @return TContainerInterface","code":"public function getContainer(): ?ContainerInterface\n {\n return $this->container;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":83,"symbol":"getRouteCollector","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getRouteCollector(): RouteCollectorInterface\n {\n return $this->routeCollector;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":91,"symbol":"getBasePath","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getBasePath(): string\n {\n return $this->routeCollector->getBasePath();\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":99,"symbol":"setBasePath","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function setBasePath(string $basePath): RouteCollectorProxyInterface\n {\n $this->routeCollector->setBasePath($basePath);\n\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":109,"symbol":"get","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function get(string $pattern, $callable): RouteInterface\n {\n return $this->map(['GET'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":117,"symbol":"post","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function post(string $pattern, $callable): RouteInterface\n {\n return $this->map(['POST'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":125,"symbol":"put","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function put(string $pattern, $callable): RouteInterface\n {\n return $this->map(['PUT'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":133,"symbol":"patch","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function patch(string $pattern, $callable): RouteInterface\n {\n return $this->map(['PATCH'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":141,"symbol":"delete","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function delete(string $pattern, $callable): RouteInterface\n {\n return $this->map(['DELETE'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":149,"symbol":"options","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function options(string $pattern, $callable): RouteInterface\n {\n return $this->map(['OPTIONS'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":157,"symbol":"any","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function any(string $pattern, $callable): RouteInterface\n {\n return $this->map(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":165,"symbol":"map","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function map(array $methods, string $pattern, $callable): RouteInterface\n {\n $pattern = $this->groupPattern . $pattern;\n\n return $this->routeCollector->map($methods, $pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":175,"symbol":"group","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function group(string $pattern, $callable): RouteGroupInterface\n {\n $pattern = $this->groupPattern . $pattern;\n\n return $this->routeCollector->group($pattern, $callable);\n }"} {"repo":"slim","file":"Slim/Routing/RouteCollectorProxy.php","line":185,"symbol":"redirect","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function redirect(string $from, $to, int $status = 302): RouteInterface\n {\n $responseFactory = $this->responseFactory;\n\n $handler = function () use ($to, $status, $responseFactory) {\n $response = $responseFactory->createResponse($status);\n return $response->withHeader('Location', (string) $to);\n };\n\n return $this->get($from, $handler);\n }"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":19,"symbol":"RouteContext","kind":"class","lang":"php","doc":"@api","code":"final class RouteContext\n{\n public const ROUTE = '__route__';\n\n public const ROUTE_PARSER = '__routeParser__';\n\n public const ROUTING_RESULTS = '__routingResults__';\n\n public const BASE_PATH = '__basePath__';\n\n public static function fromRequest(ServerRequestInterface $serverRequest): self\n {\n $route = $serverRequest->getAttribute(self::ROUTE);\n $routeParser = $serverRequest->getAttribute(self::ROUTE_PARSER);\n $routingResults = $serverRequest->getAttribute(self::ROUTING_RESULTS);\n $basePath = $serverRequest->getAttribute(self::BASE_PATH);\n\n if ($routeParser === null || $routingResults === null) {\n throw new RuntimeException('Cannot create RouteContext before routing has been completed');\n }\n\n /** @var RouteInterface|null $route */\n /** @var RouteParserInterface $routeParser */\n /** @var RoutingResults $routingResults */\n /** @var string|null $basePath */\n return new self($route, $routeParser, $routingResults, $basePath);\n }\n\n private ?RouteInterface $route;\n\n private RouteParserInterface $routeParser;\n\n private RoutingResults $routingResults;\n\n private ?string $b"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":29,"symbol":"fromRequest","kind":"method","lang":"php","code":"public static function fromRequest(ServerRequestInterface $serverRequest): self\n {\n $route = $serverRequest->getAttribute(self::ROUTE);\n $routeParser = $serverRequest->getAttribute(self::ROUTE_PARSER);\n $routingResults = $serverRequest->getAttribute(self::ROUTING_RESULTS);\n $basePath = $serverRequest->getAttribute(self::BASE_PATH);\n\n if ($routeParser === null || $routingResults === null) {\n throw new RuntimeException('Cannot create RouteContext before routing has been completed');\n }\n\n /** @var RouteInterface|null $route */\n /** @var RouteParserInterface $routeParser */\n /** @var RoutingResults $routingResults */\n /** @var string|null $basePath */\n return new self($route, $routeParser, $routingResults, $basePath);\n }"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":55,"symbol":"__construct","kind":"method","lang":"php","code":"private function __construct(\n ?RouteInterface $route,\n RouteParserInterface $routeParser,\n RoutingResults $routingResults,\n ?string $basePath = null\n ) {\n $this->route = $route;\n $this->routeParser = $routeParser;\n $this->routingResults = $routingResults;\n $this->basePath = $basePath;\n }"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":67,"symbol":"getRoute","kind":"method","lang":"php","code":"public function getRoute(): ?RouteInterface\n {\n return $this->route;\n }"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":72,"symbol":"getRouteParser","kind":"method","lang":"php","code":"public function getRouteParser(): RouteParserInterface\n {\n return $this->routeParser;\n }"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":77,"symbol":"getRoutingResults","kind":"method","lang":"php","code":"public function getRoutingResults(): RoutingResults\n {\n return $this->routingResults;\n }"} {"repo":"slim","file":"Slim/Routing/RouteContext.php","line":82,"symbol":"getBasePath","kind":"method","lang":"php","code":"public function getBasePath(): string\n {\n if ($this->basePath === null) {\n throw new RuntimeException('No base path defined.');\n }\n return $this->basePath;\n }"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":20,"symbol":"RouteGroup","kind":"class","lang":"php","code":"class RouteGroup implements RouteGroupInterface\n{\n /**\n * @var callable|string\n */\n protected $callable;\n\n protected CallableResolverInterface $callableResolver;\n\n /**\n * @var RouteCollectorProxyInterface<\\Psr\\Container\\ContainerInterface|null>\n */\n protected RouteCollectorProxyInterface $routeCollectorProxy;\n\n /**\n * @var MiddlewareInterface[]|string[]|callable[]\n */\n protected array $middleware = [];\n\n protected string $pattern;\n\n /**\n * @param callable|string $callable\n * @param RouteCollectorProxyInterface<\\Psr\\Container\\ContainerInterface|null> $routeCollectorProxy\n */\n public function __construct(\n string $pattern,\n $callable,\n CallableResolverInterface $callableResolver,\n RouteCollectorProxyInterface $routeCollectorProxy\n ) {\n $this->pattern = $pattern;\n $this->callable = $callable;\n $this->callableResolver = $callableResolver;\n $this->routeCollectorProxy = $routeCollectorProxy;\n }\n\n /**\n * {@inheritdoc}\n */\n public function collectRoutes(): RouteGroupInterface\n {\n if ($this->callableResolver instanceof AdvancedC"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":45,"symbol":"__construct","kind":"method","lang":"php","doc":"@param callable|string $callable @param RouteCollectorProxyInterface<\\Psr\\Container\\ContainerInterface|null> $routeCollectorProxy","code":"public function __construct(\n string $pattern,\n $callable,\n CallableResolverInterface $callableResolver,\n RouteCollectorProxyInterface $routeCollectorProxy\n ) {\n $this->pattern = $pattern;\n $this->callable = $callable;\n $this->callableResolver = $callableResolver;\n $this->routeCollectorProxy = $routeCollectorProxy;\n }"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":60,"symbol":"collectRoutes","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function collectRoutes(): RouteGroupInterface\n {\n if ($this->callableResolver instanceof AdvancedCallableResolverInterface) {\n $callable = $this->callableResolver->resolveRoute($this->callable);\n } else {\n $callable = $this->callableResolver->resolve($this->callable);\n }\n $callable($this->routeCollectorProxy);\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":74,"symbol":"add","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function add($middleware): RouteGroupInterface\n {\n $this->middleware[] = $middleware;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":83,"symbol":"addMiddleware","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function addMiddleware(MiddlewareInterface $middleware): RouteGroupInterface\n {\n $this->middleware[] = $middleware;\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":93,"symbol":"appendMiddlewareToDispatcher","kind":"method","lang":"php","doc":"{@inheritdoc} @param MiddlewareDispatcher<\\Psr\\Container\\ContainerInterface|null> $dispatcher","code":"public function appendMiddlewareToDispatcher(MiddlewareDispatcher $dispatcher): RouteGroupInterface\n {\n foreach ($this->middleware as $middleware) {\n $dispatcher->add($middleware);\n }\n\n return $this;\n }"} {"repo":"slim","file":"Slim/Routing/RouteGroup.php","line":105,"symbol":"getPattern","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function getPattern(): string\n {\n return $this->pattern;\n }"} {"repo":"slim","file":"Slim/Routing/RouteParser.php","line":25,"symbol":"RouteParser","kind":"class","lang":"php","code":"class RouteParser implements RouteParserInterface\n{\n private RouteCollectorInterface $routeCollector;\n\n private Std $routeParser;\n\n public function __construct(RouteCollectorInterface $routeCollector)\n {\n $this->routeCollector = $routeCollector;\n $this->routeParser = new Std();\n }\n\n /**\n * {@inheritdoc}\n */\n public function relativeUrlFor(string $routeName, array $data = [], array $queryParams = []): string\n {\n $route = $this->routeCollector->getNamedRoute($routeName);\n $pattern = $route->getPattern();\n\n $segments = [];\n $segmentName = '';\n\n /*\n * $routes is an associative array of expressions representing a route as multiple segments\n * There is an expression for each optional parameter plus one without the optional parameters\n * The most specific is last, hence why we reverse the array before iterating over it\n */\n $expressions = array_reverse($this->routeParser->parse($pattern));\n foreach ($expressions as $expression) {\n foreach ($expression as $segment) {\n /*\n * Each $segment is either a string or an array of st"} {"repo":"slim","file":"Slim/Routing/RouteParser.php","line":31,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(RouteCollectorInterface $routeCollector)\n {\n $this->routeCollector = $routeCollector;\n $this->routeParser = new Std();\n }"} {"repo":"slim","file":"Slim/Routing/RouteParser.php","line":40,"symbol":"relativeUrlFor","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function relativeUrlFor(string $routeName, array $data = [], array $queryParams = []): string\n {\n $route = $this->routeCollector->getNamedRoute($routeName);\n $pattern = $route->getPattern();\n\n $segments = [];\n $segmentName = '';\n\n /*\n * $routes is an associative array of expressions representing a route as multiple segments\n * There is an expression for each optional parameter plus one without the optional parameters\n * The most specific is last, hence why we reverse the array before iterating over it\n */\n $expressions = array_reverse($this->routeParser->parse($pattern));\n foreach ($expressions as $expression) {\n foreach ($expression as $segment) {\n /*\n * Each $segment is either a string or an array of strings\n * containing optional parameters of an expression\n */\n if (is_string($segment)) {\n $segments[] = $segment;\n continue;\n }\n\n /** @var string[] $segment */\n /*\n * If we don't have a data element for this"} {"repo":"slim","file":"Slim/Routing/RouteParser.php","line":104,"symbol":"urlFor","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function urlFor(string $routeName, array $data = [], array $queryParams = []): string\n {\n $basePath = $this->routeCollector->getBasePath();\n $url = $this->relativeUrlFor($routeName, $data, $queryParams);\n\n if ($basePath) {\n $url = $basePath . $url;\n }\n\n return $url;\n }"} {"repo":"slim","file":"Slim/Routing/RouteParser.php","line":119,"symbol":"fullUrlFor","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function fullUrlFor(UriInterface $uri, string $routeName, array $data = [], array $queryParams = []): string\n {\n $path = $this->urlFor($routeName, $data, $queryParams);\n $scheme = $uri->getScheme();\n $authority = $uri->getAuthority();\n $protocol = ($scheme ? $scheme . ':' : '') . ($authority ? '//' . $authority : '');\n return $protocol . $path;\n }"} {"repo":"slim","file":"Slim/Routing/RouteResolver.php","line":25,"symbol":"RouteResolver","kind":"class","lang":"php","doc":"RouteResolver instantiates the FastRoute dispatcher and computes the routing results of a given URI and request method","code":"class RouteResolver implements RouteResolverInterface\n{\n protected RouteCollectorInterface $routeCollector;\n\n private DispatcherInterface $dispatcher;\n\n public function __construct(RouteCollectorInterface $routeCollector, ?DispatcherInterface $dispatcher = null)\n {\n $this->routeCollector = $routeCollector;\n $this->dispatcher = $dispatcher ?? new Dispatcher($routeCollector);\n }\n\n /**\n * @param string $uri Should be $request->getUri()->getPath()\n */\n public function computeRoutingResults(string $uri, string $method): RoutingResults\n {\n $uri = rawurldecode($uri);\n if ($uri === '' || $uri[0] !== '/') {\n $uri = '/' . $uri;\n }\n return $this->dispatcher->dispatch($method, $uri);\n }\n\n /**\n * @throws RuntimeException\n */\n public function resolveRoute(string $identifier): RouteInterface\n {\n return $this->routeCollector->lookupRoute($identifier);\n }\n}"} {"repo":"slim","file":"Slim/Routing/RouteResolver.php","line":31,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(RouteCollectorInterface $routeCollector, ?DispatcherInterface $dispatcher = null)\n {\n $this->routeCollector = $routeCollector;\n $this->dispatcher = $dispatcher ?? new Dispatcher($routeCollector);\n }"} {"repo":"slim","file":"Slim/Routing/RouteResolver.php","line":40,"symbol":"computeRoutingResults","kind":"method","lang":"php","doc":"@param string $uri Should be $request->getUri()->getPath()","code":"public function computeRoutingResults(string $uri, string $method): RoutingResults\n {\n $uri = rawurldecode($uri);\n if ($uri === '' || $uri[0] !== '/') {\n $uri = '/' . $uri;\n }\n return $this->dispatcher->dispatch($method, $uri);\n }"} {"repo":"slim","file":"Slim/Routing/RouteResolver.php","line":52,"symbol":"resolveRoute","kind":"method","lang":"php","doc":"@throws RuntimeException","code":"public function resolveRoute(string $identifier): RouteInterface\n {\n return $this->routeCollector->lookupRoute($identifier);\n }"} {"repo":"slim","file":"Slim/Routing/RouteRunner.php","line":23,"symbol":"RouteRunner","kind":"class","lang":"php","code":"class RouteRunner implements RequestHandlerInterface\n{\n private RouteResolverInterface $routeResolver;\n\n private RouteParserInterface $routeParser;\n\n /**\n * @var RouteCollectorProxyInterface<\\Psr\\Container\\ContainerInterface|null>\n */\n private ?RouteCollectorProxyInterface $routeCollectorProxy;\n\n /**\n * @param RouteCollectorProxyInterface<\\Psr\\Container\\ContainerInterface|null> $routeCollectorProxy\n */\n public function __construct(\n RouteResolverInterface $routeResolver,\n RouteParserInterface $routeParser,\n ?RouteCollectorProxyInterface $routeCollectorProxy = null\n ) {\n $this->routeResolver = $routeResolver;\n $this->routeParser = $routeParser;\n $this->routeCollectorProxy = $routeCollectorProxy;\n }\n\n /**\n * This request handler is instantiated automatically in App::__construct()\n * It is at the very tip of the middleware queue meaning it will be executed\n * last and it detects whether or not routing has been performed in the user\n * defined middleware stack. In the event that the user did not perform routing\n * it is done here\n *\n * @throws HttpNotFoundException\n * @t"} {"repo":"slim","file":"Slim/Routing/RouteRunner.php","line":37,"symbol":"__construct","kind":"method","lang":"php","doc":"@param RouteCollectorProxyInterface<\\Psr\\Container\\ContainerInterface|null> $routeCollectorProxy","code":"public function __construct(\n RouteResolverInterface $routeResolver,\n RouteParserInterface $routeParser,\n ?RouteCollectorProxyInterface $routeCollectorProxy = null\n ) {\n $this->routeResolver = $routeResolver;\n $this->routeParser = $routeParser;\n $this->routeCollectorProxy = $routeCollectorProxy;\n }"} {"repo":"slim","file":"Slim/Routing/RouteRunner.php","line":57,"symbol":"handle","kind":"method","lang":"php","doc":"defined middleware stack. In the event that the user did not perform routing it is done here @throws HttpNotFoundException @throws HttpMethodNotAllowedException","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n // If routing hasn't been done, then do it now so we can dispatch\n if ($request->getAttribute(RouteContext::ROUTING_RESULTS) === null) {\n $routingMiddleware = new RoutingMiddleware($this->routeResolver, $this->routeParser);\n $request = $routingMiddleware->performRouting($request);\n }\n\n if ($this->routeCollectorProxy !== null) {\n $request = $request->withAttribute(\n RouteContext::BASE_PATH,\n $this->routeCollectorProxy->getBasePath()\n );\n }\n\n /** @var Route<\\Psr\\Container\\ContainerInterface|null> $route */\n $route = $request->getAttribute(RouteContext::ROUTE);\n return $route->run($request);\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":16,"symbol":"RoutingResults","kind":"class","lang":"php","doc":"@api","code":"class RoutingResults\n{\n public const NOT_FOUND = 0;\n public const FOUND = 1;\n public const METHOD_NOT_ALLOWED = 2;\n\n protected DispatcherInterface $dispatcher;\n\n protected string $method;\n\n protected string $uri;\n\n /**\n * The status is one of the constants shown above\n * NOT_FOUND = 0\n * FOUND = 1\n * METHOD_NOT_ALLOWED = 2\n */\n protected int $routeStatus;\n\n protected ?string $routeIdentifier = null;\n\n /**\n * @var array\n */\n protected array $routeArguments;\n\n /**\n * @param array $routeArguments\n */\n public function __construct(\n DispatcherInterface $dispatcher,\n string $method,\n string $uri,\n int $routeStatus,\n ?string $routeIdentifier = null,\n array $routeArguments = []\n ) {\n $this->dispatcher = $dispatcher;\n $this->method = $method;\n $this->uri = $uri;\n $this->routeStatus = $routeStatus;\n $this->routeIdentifier = $routeIdentifier;\n $this->routeArguments = $routeArguments;\n }\n\n public function getDispatcher(): DispatcherInterface\n {\n return $this->dispatcher;\n }\n\n publi"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":46,"symbol":"__construct","kind":"method","lang":"php","doc":"@param array $routeArguments","code":"public function __construct(\n DispatcherInterface $dispatcher,\n string $method,\n string $uri,\n int $routeStatus,\n ?string $routeIdentifier = null,\n array $routeArguments = []\n ) {\n $this->dispatcher = $dispatcher;\n $this->method = $method;\n $this->uri = $uri;\n $this->routeStatus = $routeStatus;\n $this->routeIdentifier = $routeIdentifier;\n $this->routeArguments = $routeArguments;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":62,"symbol":"getDispatcher","kind":"method","lang":"php","code":"public function getDispatcher(): DispatcherInterface\n {\n return $this->dispatcher;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":67,"symbol":"getMethod","kind":"method","lang":"php","code":"public function getMethod(): string\n {\n return $this->method;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":72,"symbol":"getUri","kind":"method","lang":"php","code":"public function getUri(): string\n {\n return $this->uri;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":77,"symbol":"getRouteStatus","kind":"method","lang":"php","code":"public function getRouteStatus(): int\n {\n return $this->routeStatus;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":82,"symbol":"getRouteIdentifier","kind":"method","lang":"php","code":"public function getRouteIdentifier(): ?string\n {\n return $this->routeIdentifier;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":96,"symbol":"getRouteArguments","kind":"method","lang":"php","doc":"@param bool $urlDecode Ignored. Retained for backwards compatibility. @return array @psalm-suppress PossiblyUnusedParam","code":"public function getRouteArguments(bool $urlDecode = true): array\n {\n return $this->routeArguments;\n }"} {"repo":"slim","file":"Slim/Routing/RoutingResults.php","line":104,"symbol":"getAllowedMethods","kind":"method","lang":"php","doc":"@return string[]","code":"public function getAllowedMethods(): array\n {\n return $this->dispatcher->getAllowedMethods($this->uri);\n }"} {"repo":"slim","file":"tests/AppTest.php","line":56,"symbol":"AppTest","kind":"class","lang":"php","code":"class AppTest extends TestCase\n{\n public static function setupBeforeClass(): void\n {\n ini_set('error_log', tempnam(sys_get_temp_dir(), 'slim'));\n }\n\n public function testDoesNotUseContainerAsServiceLocator(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n\n $containerProphecy->has(Argument::type('string'))->shouldNotHaveBeenCalled();\n $containerProphecy->get(Argument::type('string'))->shouldNotHaveBeenCalled();\n }\n\n /********************************************************************************\n * Getter methods\n *******************************************************************************/\n\n public function testGetContainer(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n\n $this->assertSame($con"} {"repo":"slim","file":"tests/AppTest.php","line":58,"symbol":"setupBeforeClass","kind":"method","lang":"php","code":"public static function setupBeforeClass(): void\n {\n ini_set('error_log', tempnam(sys_get_temp_dir(), 'slim'));\n }"} {"repo":"slim","file":"tests/AppTest.php","line":63,"symbol":"testDoesNotUseContainerAsServiceLocator","kind":"method","lang":"php","code":"public function testDoesNotUseContainerAsServiceLocator(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n\n $containerProphecy->has(Argument::type('string'))->shouldNotHaveBeenCalled();\n $containerProphecy->get(Argument::type('string'))->shouldNotHaveBeenCalled();\n }"} {"repo":"slim","file":"tests/AppTest.php","line":77,"symbol":"testGetContainer","kind":"method","lang":"php","code":"public function testGetContainer(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n\n $this->assertSame($containerProphecy->reveal(), $app->getContainer());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":86,"symbol":"testGetCallableResolverReturnsInjectedInstance","kind":"method","lang":"php","code":"public function testGetCallableResolverReturnsInjectedInstance(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $app = new App($responseFactoryProphecy->reveal(), null, $callableResolverProphecy->reveal());\n\n $this->assertSame($callableResolverProphecy->reveal(), $app->getCallableResolver());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":95,"symbol":"testCreatesCallableResolverWhenNull","kind":"method","lang":"php","code":"public function testCreatesCallableResolverWhenNull(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal(), null);\n\n $this->assertEquals($callableResolver, $app->getCallableResolver());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":105,"symbol":"testGetRouteCollectorReturnsInjectedInstance","kind":"method","lang":"php","code":"public function testGetRouteCollectorReturnsInjectedInstance(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeParserProphecy = $this->prophesize(RouteParserInterface::class);\n\n $routeCollectorProphecy->getRouteParser()->willReturn($routeParserProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal(), null, null, $routeCollectorProphecy->reveal());\n\n $this->assertSame($routeCollectorProphecy->reveal(), $app->getRouteCollector());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":118,"symbol":"testCreatesRouteCollectorWhenNullWithInjectedContainer","kind":"method","lang":"php","code":"public function testCreatesRouteCollectorWhenNullWithInjectedContainer(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $routeCollector = new RouteCollector(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $containerProphecy->reveal()\n );\n $app = new App(\n $responseFactoryProphecy->reveal(),\n $containerProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n\n $this->assertEquals($routeCollector, $app->getRouteCollector());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":137,"symbol":"testGetMiddlewareDispatcherGetsSeededAndReturnsInjectedInstance","kind":"method","lang":"php","code":"public function testGetMiddlewareDispatcherGetsSeededAndReturnsInjectedInstance(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n $middlewareDispatcherProphecy = $this->prophesize(MiddlewareDispatcherInterface::class);\n $middlewareDispatcherProphecy\n ->seedMiddlewareStack(Argument::any())\n ->shouldBeCalledOnce();\n\n $app = new App(\n $responseFactoryProphecy->reveal(),\n null,\n null,\n null,\n null,\n $middlewareDispatcherProphecy->reveal()\n );\n\n $this->assertSame($middlewareDispatcherProphecy->reveal(), $app->getMiddlewareDispatcher());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":158,"symbol":"lowerCaseRequestMethodsProvider","kind":"method","lang":"php","code":"public static function lowerCaseRequestMethodsProvider(): array\n {\n return [\n ['get'],\n ['post'],\n ['put'],\n ['patch'],\n ['delete'],\n ['options'],\n ];\n }"} {"repo":"slim","file":"tests/AppTest.php","line":174,"symbol":"testGetPostPutPatchDeleteOptionsMethods","kind":"method","lang":"php","doc":"@param string $method @dataProvider upperCaseRequestMethodsProvider()","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('upperCaseRequestMethodsProvider')]\n public function testGetPostPutPatchDeleteOptionsMethods(string $method): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn($method);\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);\n $requestProphecy->withAttribute(Argument::type('string'), Argument::any())->will(function ($args) {\n $this->getAttribute($args[0])->"} {"repo":"slim","file":"tests/AppTest.php","line":208,"symbol":"testAnyRoute","kind":"method","lang":"php","code":"public function testAnyRoute(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->any('/', function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n });\n\n foreach ($this->upperCaseRequestMethodsProvider() as $methods) {\n $method = $methods[0];\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn($method);\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttri"} {"repo":"slim","file":"tests/AppTest.php","line":248,"symbol":"upperCaseRequestMethodsProvider","kind":"method","lang":"php","code":"public static function upperCaseRequestMethodsProvider(): array\n {\n return [\n ['GET'],\n ['POST'],\n ['PUT'],\n ['PATCH'],\n ['DELETE'],\n ['OPTIONS'],\n ];\n }"} {"repo":"slim","file":"tests/AppTest.php","line":265,"symbol":"testMapRoute","kind":"method","lang":"php","doc":"@param string $method @dataProvider lowerCaseRequestMethodsProvider @dataProvider upperCaseRequestMethodsProvider","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('lowerCaseRequestMethodsProvider')]\n #[\\PHPUnit\\Framework\\Attributes\\DataProvider('upperCaseRequestMethodsProvider')]\n public function testMapRoute(string $method): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn($method);\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);\n $requestProphecy->withAttribute(Argument::type('string'), Argument::any())->will(func"} {"repo":"slim","file":"tests/AppTest.php","line":299,"symbol":"testRedirectRoute","kind":"method","lang":"php","code":"public function testRedirectRoute(): void\n {\n $from = '/from';\n $to = '/to';\n\n $routeCreatedResponse = $this->prophesize(ResponseInterface::class);\n\n $handlerCreatedResponse = $this->prophesize(ResponseInterface::class);\n $handlerCreatedResponse->getStatusCode()->willReturn(301);\n $handlerCreatedResponse->getHeaderLine('Location')->willReturn($to);\n $handlerCreatedResponse->withHeader(\n Argument::type('string'),\n Argument::type('string')\n )->will(function ($args) {\n $this->getHeader($args[0])->willReturn($args[1]);\n return $this;\n });\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($routeCreatedResponse->reveal());\n $responseFactoryProphecy->createResponse(301)->willReturn($handlerCreatedResponse->reveal());\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn($from);\n $uriProphecy->__toString()->willReturn($to);\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $reques"} {"repo":"slim","file":"tests/AppTest.php","line":343,"symbol":"testRouteWithInternationalCharacters","kind":"method","lang":"php","code":"public function testRouteWithInternationalCharacters(): void\n {\n $path = '/новости';\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get($path, function () use ($responseProphecy) {\n return $responseProphecy->reveal();\n });\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn($path);\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn('GET');\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);\n $requestProphecy->withAttribute("} {"repo":"slim","file":"tests/AppTest.php","line":382,"symbol":"routePatternsProvider","kind":"method","lang":"php","code":"public static function routePatternsProvider(): array\n {\n return [\n [''], // Empty Route\n ['/'], // Single Slash Route\n ['foo'], // Route That Does Not Start With A Slash\n ['/foo'], // Route That Does Not End In A Slash\n ['/foo/'], // Route That Ends In A Slash\n ];\n }"} {"repo":"slim","file":"tests/AppTest.php","line":397,"symbol":"testRoutePatterns","kind":"method","lang":"php","doc":"@param string $pattern @dataProvider routePatternsProvider","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('routePatternsProvider')]\n public function testRoutePatterns(string $pattern): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get($pattern, function () {\n });\n\n $routeCollector = $app->getRouteCollector();\n $route = $routeCollector->lookupRoute('route0');\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":416,"symbol":"routeGroupsDataProvider","kind":"method","lang":"php","code":"public static function routeGroupsDataProvider(): array\n {\n return [\n 'empty group with empty route' => [\n ['', ''], ''\n ],\n 'empty group with single slash route' => [\n ['', '/'], '/'\n ],\n 'empty group with segment route that does not end in aSlash' => [\n ['', '/foo'], '/foo'\n ],\n 'empty group with segment route that ends in aSlash' => [\n ['', '/foo/'], '/foo/'\n ],\n 'group single slash with empty route' => [\n ['/', ''], '/'\n ],\n 'group single slash with single slash route' => [\n ['/', '/'], '//'\n ],\n 'group single slash with segment route that does not end in aSlash' => [\n ['/', '/foo'], '//foo'\n ],\n 'group single slash with segment route that ends in aSlash' => [\n ['/', '/foo/'], '//foo/'\n ],\n 'group segment with empty route' => [\n ['/foo', ''], '/foo'\n ],\n 'group segment with single slash route' => [\n ['/foo', '/'], '"} {"repo":"slim","file":"tests/AppTest.php","line":530,"symbol":"testGroupClosureIsBoundToThisClass","kind":"method","lang":"php","code":"public function testGroupClosureIsBoundToThisClass(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $app = new App($responseFactoryProphecy->reveal());\n\n $testCase = $this;\n $app->group('/foo', function () use ($testCase) {\n $testCase->assertSame($testCase, $this);\n });\n }"} {"repo":"slim","file":"tests/AppTest.php","line":546,"symbol":"testRouteGroupCombinations","kind":"method","lang":"php","doc":"@dataProvider routeGroupsDataProvider @param array $sequence @param string $expectedPath","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('routeGroupsDataProvider')]\n public function testRouteGroupCombinations(array $sequence, string $expectedPath): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $app = new App($responseFactoryProphecy->reveal());\n\n $processSequence = function (RouteCollectorProxy $app, array $sequence, $processSequence) {\n $path = array_shift($sequence);\n\n /**\n * If sequence isn't on last element we use $app->group()\n * The very tail of the sequence uses the $app->get() method\n */\n if (count($sequence)) {\n $app->group($path, function (RouteCollectorProxy $group) use (&$sequence, $processSequence) {\n $processSequence($group, $sequence, $processSequence);\n });\n } else {\n $app->get($path, function () {\n });\n }\n };\n\n $processSequence($app, $sequence, $processSequence);\n\n $routeCollector = $app->getRouteCollector();\n $route = $routeCollector->lookupRoute('route0');\n\n $this->assertSame($expect"} {"repo":"slim","file":"tests/AppTest.php","line":577,"symbol":"testRouteGroupPattern","kind":"method","lang":"php","code":"public function testRouteGroupPattern(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n /** @var ResponseFactoryInterface $responseFactoryInterface */\n $responseFactoryInterface = $responseFactoryProphecy->reveal();\n $app = new App($responseFactoryInterface);\n $group = $app->group('/foo', function () {\n });\n\n $this->assertSame('/foo', $group->getPattern());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":594,"symbol":"testAddMiddleware","kind":"method","lang":"php","code":"public function testAddMiddleware(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(Argument::cetera())->will(function () use ($responseProphecy) {\n return $responseProphecy->reveal();\n });\n\n $middlewareProphecy2 = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy2->process(\n Argument::type(ServerRequestInterface::class),\n Argument::type(RequestHandlerInterface::class)\n )->will(function ($args) {\n /** @var ServerRequestInterface $request */\n $request = $args[0];\n\n /** @var Req"} {"repo":"slim","file":"tests/AppTest.php","line":658,"symbol":"testAddMiddlewareUsingDeferredResolution","kind":"method","lang":"php","code":"public function testAddMiddlewareUsingDeferredResolution(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(Argument::cetera())->willReturn($responseProphecy->reveal());\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('middleware')->willReturn(true);\n $containerProphecy->get('middleware')->willReturn($middlewareProphecy);\n\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n $app->add('middleware');\n $app->get('/', function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n });\n\n"} {"repo":"slim","file":"tests/AppTest.php","line":693,"symbol":"testAddRoutingMiddleware","kind":"method","lang":"php","code":"public function testAddRoutingMiddleware(): void\n {\n /** @var ResponseFactoryInterface $responseFactory */\n $responseFactory = $this->prophesize(ResponseFactoryInterface::class)->reveal();\n\n // Create the app.\n $app = new App($responseFactory);\n\n // Add the routing middleware.\n $routingMiddleware = $app->addRoutingMiddleware();\n\n // Check that the routing middleware really has been added to the tip of the app middleware stack.\n $middlewareDispatcherProperty = new ReflectionProperty(App::class, 'middlewareDispatcher');\n $this->setAccessible($middlewareDispatcherProperty);\n /** @var MiddlewareDispatcher $middlewareDispatcher */\n $middlewareDispatcher = $middlewareDispatcherProperty->getValue($app);\n\n $tipProperty = new ReflectionProperty(MiddlewareDispatcher::class, 'tip');\n $this->setAccessible($tipProperty);\n /** @var RequestHandlerInterface $tip */\n $tip = $tipProperty->getValue($middlewareDispatcher);\n\n $reflection = new ReflectionClass($tip);\n $middlewareProperty = $reflection->getProperty('middleware');\n $this->setAccessible($middlewareProperty);\n\n "} {"repo":"slim","file":"tests/AppTest.php","line":723,"symbol":"testAddErrorMiddleware","kind":"method","lang":"php","code":"public function testAddErrorMiddleware(): void\n {\n /** @var ResponseFactoryInterface $responseFactory */\n $responseFactory = $this->prophesize(ResponseFactoryInterface::class)->reveal();\n\n /** @var LoggerInterface $logger */\n $logger = $this->prophesize(LoggerInterface::class)->reveal();\n\n // Create the app.\n $app = new App($responseFactory);\n\n // Add the error middleware.\n $errorMiddleware = $app->addErrorMiddleware(true, true, true, $logger);\n\n // Check that the error middleware really has been added to the tip of the app middleware stack.\n $middlewareDispatcherProperty = new ReflectionProperty(App::class, 'middlewareDispatcher');\n $this->setAccessible($middlewareDispatcherProperty);\n /** @var MiddlewareDispatcher $middlewareDispatcher */\n $middlewareDispatcher = $middlewareDispatcherProperty->getValue($app);\n\n $tipProperty = new ReflectionProperty(MiddlewareDispatcher::class, 'tip');\n $this->setAccessible($tipProperty);\n /** @var RequestHandlerInterface $tip */\n $tip = $tipProperty->getValue($middlewareDispatcher);\n\n $reflection = new ReflectionClass($"} {"repo":"slim","file":"tests/AppTest.php","line":756,"symbol":"testAddBodyParsingMiddleware","kind":"method","lang":"php","code":"public function testAddBodyParsingMiddleware(): void\n {\n /** @var ResponseFactoryInterface $responseFactory */\n $responseFactory = $this->prophesize(ResponseFactoryInterface::class)->reveal();\n\n // Create the app.\n $app = new App($responseFactory);\n\n // Add the error middleware.\n $bodyParsingMiddleware = $app->addBodyParsingMiddleware();\n\n // Check that the body parsing middleware really has been added to the tip of the app middleware stack.\n $middlewareDispatcherProperty = new ReflectionProperty(App::class, 'middlewareDispatcher');\n $this->setAccessible($middlewareDispatcherProperty);\n /** @var MiddlewareDispatcher $middlewareDispatcher */\n $middlewareDispatcher = $middlewareDispatcherProperty->getValue($app);\n\n $tipProperty = new ReflectionProperty(MiddlewareDispatcher::class, 'tip');\n $this->setAccessible($tipProperty);\n /** @var RequestHandlerInterface $tip */\n $tip = $tipProperty->getValue($middlewareDispatcher);\n\n $reflection = new ReflectionClass($tip);\n $middlewareProperty = $reflection->getProperty('middleware');\n $this->setAccessible($middleware"} {"repo":"slim","file":"tests/AppTest.php","line":786,"symbol":"testAddMiddlewareOnRoute","kind":"method","lang":"php","code":"public function testAddMiddlewareOnRoute(): void\n {\n $output = '';\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(\n Argument::type(ServerRequestInterface::class),\n Argument::type(RequestHandlerInterface::class)\n )->will(function ($args) use (&$output) {\n /** @var ServerRequestInterface $request */\n $request = $args[0];\n\n /** @var RequestHandlerInterface $handler */\n $handler = $args[1];\n\n $output .= 'In1';\n\n /** @var ResponseInterface $response */\n $response = $handler->handle($request);\n\n $output .= 'Out1';\n\n return $re"} {"repo":"slim","file":"tests/AppTest.php","line":866,"symbol":"testAddMiddlewareOnRouteGroup","kind":"method","lang":"php","code":"public function testAddMiddlewareOnRouteGroup(): void\n {\n $output = '';\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(\n Argument::type(ServerRequestInterface::class),\n Argument::type(RequestHandlerInterface::class)\n )->will(function ($args) use (&$output) {\n /** @var ServerRequestInterface $request */\n $request = $args[0];\n\n /** @var RequestHandlerInterface $handler */\n $handler = $args[1];\n\n $output .= 'In1';\n\n /** @var ResponseInterface $response */\n $response = $handler->handle($request);\n\n $output .= 'Out1';\n\n retur"} {"repo":"slim","file":"tests/AppTest.php","line":948,"symbol":"testAddMiddlewareOnTwoRouteGroup","kind":"method","lang":"php","code":"public function testAddMiddlewareOnTwoRouteGroup(): void\n {\n $output = '';\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(\n Argument::type(ServerRequestInterface::class),\n Argument::type(RequestHandlerInterface::class)\n )->will(function ($args) use (&$output) {\n /** @var ServerRequestInterface $request */\n $request = $args[0];\n\n /** @var RequestHandlerInterface $handler */\n $handler = $args[1];\n\n $output .= 'In1';\n\n /** @var ResponseInterface $response */\n $response = $handler->handle($request);\n\n $output .= 'Out1';\n\n re"} {"repo":"slim","file":"tests/AppTest.php","line":1068,"symbol":"testAddMiddlewareAsStringNotImplementingInterfaceThrowsException","kind":"method","lang":"php","code":"public function testAddMiddlewareAsStringNotImplementingInterfaceThrowsException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage(\n 'A middleware must be an object/class name referencing an implementation of ' .\n 'MiddlewareInterface or a callable with a matching signature.'\n );\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $app = new App($responseFactoryProphecy->reveal());\n $app->add(new stdClass());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":1085,"symbol":"testInvokeReturnMethodNotAllowed","kind":"method","lang":"php","code":"public function testInvokeReturnMethodNotAllowed(): void\n {\n $this->expectException(HttpMethodNotAllowedException::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/', function () {\n });\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn('POST');\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);\n $requestProphecy->withAttribute(Argument::type('string'), Argument::any())->will(function ($args) {\n $this->getAttribute($args[0])->willReturn($args[1]);\n return $this;\n });\n\n $app->handle($requestProphecy->reveal());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":1109,"symbol":"testInvokeWithMatchingRoute","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRoute(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/', function (ServerRequestInterface $request, $response) {\n return $response;\n });\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn('GET');\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);\n $requestProphecy->withAttribute(Argument::type('string'), Argument::any())"} {"repo":"slim","file":"tests/AppTest.php","line":1143,"symbol":"testInvokeWithMatchingRouteWithSetArgument","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRouteWithSetArgument(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write(\"Hello {$args['name']}\");\n return $response;\n })->setArgument('name', 'World');\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n "} {"repo":"slim","file":"tests/AppTest.php","line":1184,"symbol":"testInvokeWithMatchingRouteWithSetArguments","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRouteWithSetArguments(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write(\"{$args['greeting']} {$args['name']}\");\n return $response;\n })->setArguments(['greeting' => 'Hello', 'name' => 'World']);\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $ur"} {"repo":"slim","file":"tests/AppTest.php","line":1225,"symbol":"testInvokeWithMatchingRouteWithNamedParameterRequestResponseStrategy","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseStrategy(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/Hello/{name}', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write(\"Hello {$args['name']}\");\n return $response;\n });\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/"} {"repo":"slim","file":"tests/AppTest.php","line":1266,"symbol":"testInvokeWithMatchingRouteWithNamedParameterRequestResponseArgStrategy","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseArgStrategy(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->getRouteCollector()->setDefaultInvocationStrategy(new RequestResponseArgs());\n $app->get('/Hello/{name}', function (ServerRequestInterface $request, ResponseInterface $response, $name) {\n $response->getBody()->write(\"Hello {$name}\");\n return $response;\n });\n\n $uriProphecy ="} {"repo":"slim","file":"tests/AppTest.php","line":1308,"symbol":"testInvokeWithMatchingRouteWithNamedParameterRequestResponseNamedArgsStrategy","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseNamedArgsStrategy(): void\n {\n if (PHP_VERSION_ID < 80000) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->getRouteCollector()->setDefaultInvocationStrategy(new RequestResponseNamedArgs());\n $app->get(\n '/{greeting}/{name}',\n function (Se"} {"repo":"slim","file":"tests/AppTest.php","line":1357,"symbol":"testInvokeWithMatchingRouteWithNamedParameterOverwritesSetArgument","kind":"method","lang":"php","code":"public function testInvokeWithMatchingRouteWithNamedParameterOverwritesSetArgument(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/Hello/{name}', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write(\"Hello {$args['name']}\");\n return $response;\n })->setArgument('name', 'World!');\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProph"} {"repo":"slim","file":"tests/AppTest.php","line":1398,"symbol":"testInvokeWithoutMatchingRoute","kind":"method","lang":"php","code":"public function testInvokeWithoutMatchingRoute(): void\n {\n $this->expectException(HttpNotFoundException::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $app = new App($responseFactoryProphecy->reveal());\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn('GET');\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);\n $requestProphecy->withAttribute(Argument::type('string'), Argument::any())->will(function ($args) {\n $this->getAttribute($args[0])->willReturn($args[1]);\n return $this;\n });\n\n $app->handle($requestProphecy->reveal());\n }"} {"repo":"slim","file":"tests/AppTest.php","line":1420,"symbol":"testInvokeWithCallableRegisteredInContainer","kind":"method","lang":"php","code":"public function testInvokeWithCallableRegisteredInContainer(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $handler = new class\n {\n public function foo(ServerRequestInterface $request, ResponseInterface $response)\n {\n return $response;\n }\n };\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('handler')->willReturn(true);\n $containerProphecy->get('handler')->willReturn($handler);\n\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n $app->get('/', 'handler:foo');\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n "} {"repo":"slim","file":"tests/AppTest.php","line":1433,"symbol":"foo","kind":"method","lang":"php","code":"public function foo(ServerRequestInterface $request, ResponseInterface $response)\n {\n return $response;\n }"} {"repo":"slim","file":"tests/AppTest.php","line":1464,"symbol":"testInvokeWithNonExistentMethodOnCallableRegisteredInContainer","kind":"method","lang":"php","code":"public function testInvokeWithNonExistentMethodOnCallableRegisteredInContainer(): void\n {\n $this->expectException(RuntimeException::class);\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $handler = new class\n {\n };\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('handler')->willReturn(true);\n $containerProphecy->get('handler')->willReturn($handler);\n\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n $app->get('/', 'handler:method_does_not_exist');\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getMethod()->willReturn('GET');\n $requestProphecy->getUri()->willReturn($uriProphecy->reveal());\n $requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)-"} {"repo":"slim","file":"tests/AppTest.php","line":1500,"symbol":"testInvokeWithCallableInContainerViaCallMagicMethod","kind":"method","lang":"php","code":"public function testInvokeWithCallableInContainerViaCallMagicMethod(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $mockAction = new MockAction();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('handler')->willReturn(true);\n $containerProphecy->get('handler')->willReturn($mockAction);\n\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n $app->get('/', 'handler:foo');\n\n $uriProphecy = $this->pro"} {"repo":"slim","file":"tests/AppTest.php","line":1545,"symbol":"testInvokeFunctionName","kind":"method","lang":"php","code":"public function testInvokeFunctionName(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n // @codingStandardsIgnoreStart\n function handle($request, ResponseInterface $response)\n {\n $response->getBody()->write('Hello World');\n return $response;\n }\n\n // @codingStandardsIgnoreEnd\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/', __NAMESPACE__ . '\\handle');\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphe"} {"repo":"slim","file":"tests/AppTest.php","line":1563,"symbol":"handle","kind":"function","lang":"php","doc":"@codingStandardsIgnoreStart","code":"function handle($request, ResponseInterface $response)\n {\n $response->getBody()->write('Hello World');\n return $response;\n }"} {"repo":"slim","file":"tests/AppTest.php","line":1592,"symbol":"testCurrentRequestAttributesAreNotLostWhenAddingRouteArguments","kind":"method","lang":"php","code":"public function testCurrentRequestAttributesAreNotLostWhenAddingRouteArguments(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/Hello/{name}', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write($request->getAttribute('greeting') . ' ' . $args['name']);\n return $response;\n });\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphec"} {"repo":"slim","file":"tests/AppTest.php","line":1633,"symbol":"testCurrentRequestAttributesAreNotLostWhenAddingRouteArgumentsRequestResponseArg","kind":"method","lang":"php","code":"public function testCurrentRequestAttributesAreNotLostWhenAddingRouteArgumentsRequestResponseArg(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->getRouteCollector()->setDefaultInvocationStrategy(new RequestResponseArgs());\n $app->get('/Hello/{name}', function (ServerRequestInterface $request, ResponseInterface $response, $name) {\n $response->getBody()->write($request->getAttribute('greeting') . ' ' . $name);\n return $res"} {"repo":"slim","file":"tests/AppTest.php","line":1675,"symbol":"testRun","kind":"method","lang":"php","code":"public function testRun(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n $streamProphecy->read(1)->willReturn('_');\n $streamProphecy->read('11')->will(function () {\n $this->eof()->willReturn(true);\n return $this->reveal()->__toString();\n });\n $streamProphecy->eof()->willReturn(false);\n $streamProphecy->isSeekable()->willReturn(true);\n $streamProphecy->rewind()->shouldBeCalled();\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n $responseProphecy->getStatusCode()->willReturn(200);\n $responseProphecy->getHeaders()->willReturn(['Content-Length' => ['11']]);\n $responseProphecy->getProtocolVersion()->willReturn('1.1');\n $responseProphecy->getReasonPhrase()->willR"} {"repo":"slim","file":"tests/AppTest.php","line":1728,"symbol":"testRunWithoutPassingInServerRequest","kind":"method","lang":"php","code":"public function testRunWithoutPassingInServerRequest(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n $streamProphecy->read(1)->willReturn('_');\n $streamProphecy->read(11)->will(function () {\n $this->eof()->willReturn(true);\n return $this->reveal()->__toString();\n });\n $streamProphecy->eof()->willReturn(false);\n $streamProphecy->isSeekable()->willReturn(true);\n $streamProphecy->rewind()->shouldBeCalled();\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n $responseProphecy->getStatusCode()->willReturn(200);\n $responseProphecy->getHeaders()->willReturn(['Content-Length' => ['11']]);\n $responseProphecy->getProtocolVersion()->willReturn('1.1');\n $responseProphec"} {"repo":"slim","file":"tests/AppTest.php","line":1769,"symbol":"testHandleReturnsEmptyResponseBodyWithHeadRequestMethod","kind":"method","lang":"php","code":"public function testHandleReturnsEmptyResponseBodyWithHeadRequestMethod(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n $responseProphecy\n ->withBody(Argument::type(StreamInterface::class))\n ->will(function ($args) {\n $this->getBody()->willReturn($args[0]);\n return $this;\n });\n\n $emptyStreamProphecy = $this->prophesize(StreamInterface::class);\n $emptyStreamProphecy->__toString()->willReturn('');\n $emptyResponseProphecy = $this->prophesize(ResponseInterface::class);\n $emptyResponseProphecy->getBody()->willReturn($emptyStreamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(Respon"} {"repo":"slim","file":"tests/AppTest.php","line":1826,"symbol":"testCanBeReExecutedRecursivelyDuringDispatch","kind":"method","lang":"php","code":"public function testCanBeReExecutedRecursivelyDuringDispatch(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseHeaders = [];\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n $responseProphecy->getStatusCode()->willReturn(200);\n $responseProphecy->getHeader(Argument::type('string'))->will(function ($args) use (&$responseHeaders) {\n return $responseHeaders[$args[0]];\n });\n $responseProphecy->withAddedHeader(\n Argument::type('string'),\n Argument::type('string')\n )->will(function ($args) use (&$responseHeaders) {\n $key = $args[0];\n $value = $args[1];\n if (!isset($responseHeaders[$key])) {\n $responseHeaders[$key] = [];\n "} {"repo":"slim","file":"tests/AppTest.php","line":1946,"symbol":"testContainerSetToRoute","kind":"method","lang":"php","code":"public function testContainerSetToRoute(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('Hello World');\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('handler')->willReturn(true);\n $containerProphecy->get('handler')->willReturn(function () use ($responseProphecy) {\n return $responseProphecy->reveal();\n });\n\n $app = new App($responseFactoryProphecy->reveal(), $containerProphecy->reveal());\n $routeCollector = $app->getRouteCollector();\n $routeCollector->map(['GET'], '/', 'handler');\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willReturn('/');\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class"} {"repo":"slim","file":"tests/AppTest.php","line":1984,"symbol":"testAppIsARequestHandler","kind":"method","lang":"php","code":"public function testAppIsARequestHandler(): void\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $app = new App($responseFactoryProphecy->reveal());\n\n $this->assertInstanceOf(RequestHandlerInterface::class, $app);\n }"} {"repo":"slim","file":"tests/AppTest.php","line":1992,"symbol":"testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOptionalArgs","kind":"method","lang":"php","code":"public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOptionalArgs(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/Hello[/{name}]', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write((string) count($args));\n return $response;\n });\n\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy->getPath()->willRetur"} {"repo":"slim","file":"tests/AppTest.php","line":2047,"symbol":"testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOptionalArgsAndKeepSetedArgs","kind":"method","lang":"php","code":"public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOptionalArgsAndKeepSetedArgs(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $app->get('/Hello[/{name}]', function (ServerRequestInterface $request, ResponseInterface $response, $args) {\n $response->getBody()->write((string) count($args));\n return $response;\n })->setArgument('extra', 'value');\n\n $uriProphecy = $this->prophesize(UriInterface::cla"} {"repo":"slim","file":"tests/AppTest.php","line":2102,"symbol":"testInvokeSequentialProcessAfterAddingAnotherRouteArgument","kind":"method","lang":"php","code":"public function testInvokeSequentialProcessAfterAddingAnotherRouteArgument(): void\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n $streamProphecy->__toString()->willReturn('');\n $streamProphecy->write(Argument::type('string'))->will(function ($args) {\n $body = $this->reveal()->__toString();\n $body .= $args[0];\n $this->__toString()->willReturn($body);\n return 0;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getBody()->willReturn($streamProphecy->reveal());\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy->createResponse()->willReturn($responseProphecy->reveal());\n\n $app = new App($responseFactoryProphecy->reveal());\n $route = $app->get('/Hello[/{name}]', function (\n ServerRequestInterface $request,\n ResponseInterface $response,\n $args\n ) {\n $response->getBody()->write((string) count($args));\n return $response;\n })->setArgument('extra', 'value');\n\n $uriProphecy = $this->pro"} {"repo":"slim","file":"tests/Assets/HeaderStack.php","line":41,"symbol":"HeaderStack","kind":"class","lang":"php","doc":"Store output artifacts","code":"class HeaderStack\n{\n /**\n * @var string[][]\n */\n private static $data = [];\n\n /**\n * Reset state\n */\n public static function reset()\n {\n self::$data = [];\n }\n\n /**\n * Push a header on the stack\n *\n * @param array $header\n */\n public static function push(array $header)\n {\n self::$data[] = $header;\n }\n\n /**\n * Return the current header stack\n *\n * @return string[][]\n */\n public static function stack()\n {\n return self::$data;\n }\n\n /**\n * Verify if there's a header line on the stack\n *\n * @param string $header\n *\n * @return bool\n */\n public static function has($header)\n {\n foreach (self::$data as $item) {\n $components = explode(':', $item['header']);\n if (trim($components[0]) === $header) {\n return true;\n }\n }\n return false;\n }\n}"} {"repo":"slim","file":"tests/Assets/HeaderStack.php","line":51,"symbol":"reset","kind":"method","lang":"php","doc":"Reset state","code":"public static function reset()\n {\n self::$data = [];\n }"} {"repo":"slim","file":"tests/Assets/HeaderStack.php","line":61,"symbol":"push","kind":"method","lang":"php","doc":"Push a header on the stack @param array $header","code":"public static function push(array $header)\n {\n self::$data[] = $header;\n }"} {"repo":"slim","file":"tests/Assets/HeaderStack.php","line":71,"symbol":"stack","kind":"method","lang":"php","doc":"Return the current header stack @return string[][]","code":"public static function stack()\n {\n return self::$data;\n }"} {"repo":"slim","file":"tests/Assets/HeaderStack.php","line":83,"symbol":"has","kind":"method","lang":"php","doc":"Verify if there's a header line on the stack @param string $header @return bool","code":"public static function has($header)\n {\n foreach (self::$data as $item) {\n $components = explode(':', $item['header']);\n if (trim($components[0]) === $header) {\n return true;\n }\n }\n return false;\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":24,"symbol":"CallableResolverTest","kind":"class","lang":"php","code":"class CallableResolverTest extends TestCase\n{\n private ObjectProphecy $containerProphecy;\n\n public static function setUpBeforeClass(): void\n {\n function testAdvancedCallable()\n {\n return true;\n }\n }\n\n public function setUp(): void\n {\n CallableTest::$CalledCount = 0;\n InvokableTest::$CalledCount = 0;\n RequestHandlerTest::$CalledCount = 0;\n\n $this->containerProphecy = $this->prophesize(ContainerInterface::class);\n $this->containerProphecy->has(Argument::type('string'))->willReturn(false);\n }\n\n public function testClosure(): void\n {\n $test = function () {\n return true;\n };\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve($test);\n $callableRoute = $resolver->resolveRoute($test);\n $callableMiddleware = $resolver->resolveMiddleware($test);\n\n $this->assertTrue($callable());\n $this->assertTrue($callableRoute());\n $this->assertTrue($callableMiddleware());\n }\n\n public function testClosureContainer(): void\n {\n $this->containerProphecy->has('ultimateAnswer')->willRetur"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":28,"symbol":"setUpBeforeClass","kind":"method","lang":"php","code":"public static function setUpBeforeClass(): void\n {\n function testAdvancedCallable()\n {\n return true;\n }\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":30,"symbol":"testAdvancedCallable","kind":"function","lang":"php","code":"function testAdvancedCallable()\n {\n return true;\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":36,"symbol":"setUp","kind":"method","lang":"php","code":"public function setUp(): void\n {\n CallableTest::$CalledCount = 0;\n InvokableTest::$CalledCount = 0;\n RequestHandlerTest::$CalledCount = 0;\n\n $this->containerProphecy = $this->prophesize(ContainerInterface::class);\n $this->containerProphecy->has(Argument::type('string'))->willReturn(false);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":46,"symbol":"testClosure","kind":"method","lang":"php","code":"public function testClosure(): void\n {\n $test = function () {\n return true;\n };\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve($test);\n $callableRoute = $resolver->resolveRoute($test);\n $callableMiddleware = $resolver->resolveMiddleware($test);\n\n $this->assertTrue($callable());\n $this->assertTrue($callableRoute());\n $this->assertTrue($callableMiddleware());\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":61,"symbol":"testClosureContainer","kind":"method","lang":"php","code":"public function testClosureContainer(): void\n {\n $this->containerProphecy->has('ultimateAnswer')->willReturn(true);\n $this->containerProphecy->get('ultimateAnswer')->willReturn(42);\n\n $that = $this;\n $test = function () use ($that) {\n $that->assertInstanceOf(ContainerInterface::class, $this);\n\n /** @var ContainerInterface $this */\n return $this->get('ultimateAnswer');\n };\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $callable = $resolver->resolve($test);\n $callableRoute = $resolver->resolveRoute($test);\n $callableMiddleware = $resolver->resolveMiddleware($test);\n\n $this->assertSame(42, $callable());\n $this->assertSame(42, $callableRoute());\n $this->assertSame(42, $callableMiddleware());\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":86,"symbol":"testFunctionName","kind":"method","lang":"php","code":"public function testFunctionName(): void\n {\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve(__NAMESPACE__ . '\\testAdvancedCallable');\n $callableRoute = $resolver->resolveRoute(__NAMESPACE__ . '\\testAdvancedCallable');\n $callableMiddleware = $resolver->resolveMiddleware(__NAMESPACE__ . '\\testAdvancedCallable');\n\n $this->assertTrue($callable());\n $this->assertTrue($callableRoute());\n $this->assertTrue($callableMiddleware());\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":98,"symbol":"testObjMethodArray","kind":"method","lang":"php","code":"public function testObjMethodArray(): void\n {\n $obj = new CallableTest();\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve([$obj, 'toCall']);\n $callableRoute = $resolver->resolveRoute([$obj, 'toCall']);\n $callableMiddleware = $resolver->resolveMiddleware([$obj, 'toCall']);\n\n $callable();\n $this->assertSame(1, CallableTest::$CalledCount);\n\n $callableRoute();\n $this->assertSame(2, CallableTest::$CalledCount);\n\n $callableMiddleware();\n $this->assertSame(3, CallableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":116,"symbol":"testSlimCallable","kind":"method","lang":"php","code":"public function testSlimCallable(): void\n {\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve('Slim\\Tests\\Mocks\\CallableTest:toCall');\n $callableRoute = $resolver->resolveRoute('Slim\\Tests\\Mocks\\CallableTest:toCall');\n $callableMiddleware = $resolver->resolveMiddleware('Slim\\Tests\\Mocks\\CallableTest:toCall');\n\n $callable();\n $this->assertSame(1, CallableTest::$CalledCount);\n\n $callableRoute();\n $this->assertSame(2, CallableTest::$CalledCount);\n\n $callableMiddleware();\n $this->assertSame(3, CallableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":133,"symbol":"testSlimCallableAsArray","kind":"method","lang":"php","code":"public function testSlimCallableAsArray(): void\n {\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve([CallableTest::class, 'toCall']);\n $callableRoute = $resolver->resolveRoute([CallableTest::class, 'toCall']);\n $callableMiddleware = $resolver->resolveMiddleware([CallableTest::class, 'toCall']);\n\n $callable();\n $this->assertSame(1, CallableTest::$CalledCount);\n\n $callableRoute();\n $this->assertSame(2, CallableTest::$CalledCount);\n\n $callableMiddleware();\n $this->assertSame(3, CallableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":150,"symbol":"testSlimCallableContainer","kind":"method","lang":"php","code":"public function testSlimCallableContainer(): void\n {\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve('Slim\\Tests\\Mocks\\CallableTest:toCall');\n $this->assertSame($container, CallableTest::$CalledContainer);\n\n CallableTest::$CalledContainer = null;\n $resolver->resolveRoute('Slim\\Tests\\Mocks\\CallableTest:toCall');\n $this->assertSame($container, CallableTest::$CalledContainer);\n\n CallableTest::$CalledContainer = null;\n $resolver->resolveMiddleware('Slim\\Tests\\Mocks\\CallableTest:toCall');\n $this->assertSame($container, CallableTest::$CalledContainer);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":167,"symbol":"testSlimCallableAsArrayContainer","kind":"method","lang":"php","code":"public function testSlimCallableAsArrayContainer(): void\n {\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve([CallableTest::class, 'toCall']);\n $this->assertSame($container, CallableTest::$CalledContainer);\n\n CallableTest::$CalledContainer = null;\n $resolver->resolveRoute([CallableTest::class, 'toCall']);\n $this->assertSame($container, CallableTest::$CalledContainer);\n\n CallableTest::$CalledContainer = null;\n $resolver->resolveMiddleware([CallableTest::class ,'toCall']);\n $this->assertSame($container, CallableTest::$CalledContainer);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":184,"symbol":"testContainer","kind":"method","lang":"php","code":"public function testContainer(): void\n {\n $this->containerProphecy->has('callable_service')->willReturn(true);\n $this->containerProphecy->get('callable_service')->willReturn(new CallableTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n\n $resolver = new CallableResolver($container);\n $callable = $resolver->resolve('callable_service:toCall');\n $callableRoute = $resolver->resolveRoute('callable_service:toCall');\n $callableMiddleware = $resolver->resolveMiddleware('callable_service:toCall');\n\n $callable();\n $this->assertSame(1, CallableTest::$CalledCount);\n\n $callableRoute();\n $this->assertSame(2, CallableTest::$CalledCount);\n\n $callableMiddleware();\n $this->assertSame(3, CallableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":207,"symbol":"testResolutionToAnInvokableClassInContainer","kind":"method","lang":"php","code":"public function testResolutionToAnInvokableClassInContainer(): void\n {\n $this->containerProphecy->has('an_invokable')->willReturn(true);\n $this->containerProphecy->get('an_invokable')->willReturn(new InvokableTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n\n $resolver = new CallableResolver($container);\n $callable = $resolver->resolve('an_invokable');\n $callableRoute = $resolver->resolveRoute('an_invokable');\n $callableMiddleware = $resolver->resolveMiddleware('an_invokable');\n\n $callable();\n $this->assertSame(1, InvokableTest::$CalledCount);\n\n $callableRoute();\n $this->assertSame(2, InvokableTest::$CalledCount);\n\n $callableMiddleware();\n $this->assertSame(3, InvokableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":230,"symbol":"testResolutionToAnInvokableClass","kind":"method","lang":"php","code":"public function testResolutionToAnInvokableClass(): void\n {\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve('Slim\\Tests\\Mocks\\InvokableTest');\n $callableRoute = $resolver->resolveRoute('Slim\\Tests\\Mocks\\InvokableTest');\n $callableMiddleware = $resolver->resolveMiddleware('Slim\\Tests\\Mocks\\InvokableTest');\n\n $callable();\n $this->assertSame(1, InvokableTest::$CalledCount);\n\n $callableRoute();\n $this->assertSame(2, InvokableTest::$CalledCount);\n\n $callableMiddleware();\n $this->assertSame(3, InvokableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":247,"symbol":"testResolutionToAPsrRequestHandlerClass","kind":"method","lang":"php","code":"public function testResolutionToAPsrRequestHandlerClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\RequestHandlerTest is not resolvable');\n\n $resolver = new CallableResolver(); // No container injected\n $resolver->resolve(RequestHandlerTest::class);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":256,"symbol":"testRouteResolutionToAPsrRequestHandlerClass","kind":"method","lang":"php","code":"public function testRouteResolutionToAPsrRequestHandlerClass(): void\n {\n $request = $this->createServerRequest('/', 'GET');\n $resolver = new CallableResolver(); // No container injected\n $callableRoute = $resolver->resolveRoute(RequestHandlerTest::class);\n $callableRoute($request);\n $this->assertSame(1, RequestHandlerTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":265,"symbol":"testMiddlewareResolutionToAPsrRequestHandlerClass","kind":"method","lang":"php","code":"public function testMiddlewareResolutionToAPsrRequestHandlerClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\RequestHandlerTest is not resolvable');\n\n $resolver = new CallableResolver(); // No container injected\n $resolver->resolveMiddleware(RequestHandlerTest::class);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":274,"symbol":"testObjPsrRequestHandlerClass","kind":"method","lang":"php","code":"public function testObjPsrRequestHandlerClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('{} is not resolvable');\n\n $obj = new RequestHandlerTest();\n $resolver = new CallableResolver(); // No container injected\n $resolver->resolve($obj);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":284,"symbol":"testRouteObjPsrRequestHandlerClass","kind":"method","lang":"php","code":"public function testRouteObjPsrRequestHandlerClass(): void\n {\n $obj = new RequestHandlerTest();\n $request = $this->createServerRequest('/', 'GET');\n $resolver = new CallableResolver(); // No container injected\n $callableRoute = $resolver->resolveRoute($obj);\n $callableRoute($request);\n $this->assertSame(1, RequestHandlerTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":294,"symbol":"testMiddlewareObjPsrRequestHandlerClass","kind":"method","lang":"php","code":"public function testMiddlewareObjPsrRequestHandlerClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('{} is not resolvable');\n\n $obj = new RequestHandlerTest();\n $resolver = new CallableResolver(); // No container injected\n $resolver->resolveMiddleware($obj);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":304,"symbol":"testObjPsrRequestHandlerClassInContainer","kind":"method","lang":"php","code":"public function testObjPsrRequestHandlerClassInContainer(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('a_requesthandler is not resolvable');\n\n $this->containerProphecy->has('a_requesthandler')->willReturn(true);\n $this->containerProphecy->get('a_requesthandler')->willReturn(new RequestHandlerTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve('a_requesthandler');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":318,"symbol":"testRouteObjPsrRequestHandlerClassInContainer","kind":"method","lang":"php","code":"public function testRouteObjPsrRequestHandlerClassInContainer(): void\n {\n $this->containerProphecy->has('a_requesthandler')->willReturn(true);\n $this->containerProphecy->get('a_requesthandler')->willReturn(new RequestHandlerTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $request = $this->createServerRequest('/', 'GET');\n $resolver = new CallableResolver($container);\n $callable = $resolver->resolveRoute('a_requesthandler');\n $callable($request);\n\n $this->assertSame(1, RequestHandlerTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":333,"symbol":"testMiddlewareObjPsrRequestHandlerClassInContainer","kind":"method","lang":"php","code":"public function testMiddlewareObjPsrRequestHandlerClassInContainer(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('a_requesthandler is not resolvable');\n\n $this->containerProphecy->has('a_requesthandler')->willReturn(true);\n $this->containerProphecy->get('a_requesthandler')->willReturn(new RequestHandlerTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveMiddleware('a_requesthandler');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":347,"symbol":"testResolutionToAPsrRequestHandlerClassWithCustomMethod","kind":"method","lang":"php","code":"public function testResolutionToAPsrRequestHandlerClassWithCustomMethod(): void\n {\n $resolver = new CallableResolver(); // No container injected\n $callable = $resolver->resolve(RequestHandlerTest::class . ':custom');\n $callableRoute = $resolver->resolveRoute(RequestHandlerTest::class . ':custom');\n $callableMiddleware = $resolver->resolveMiddleware(RequestHandlerTest::class . ':custom');\n\n $this->assertIsArray($callable);\n $this->assertInstanceOf(RequestHandlerTest::class, $callable[0]);\n $this->assertSame('custom', $callable[1]);\n\n $this->assertIsArray($callableRoute);\n $this->assertInstanceOf(RequestHandlerTest::class, $callableRoute[0]);\n $this->assertSame('custom', $callableRoute[1]);\n\n $this->assertIsArray($callableMiddleware);\n $this->assertInstanceOf(RequestHandlerTest::class, $callableMiddleware[0]);\n $this->assertSame('custom', $callableMiddleware[1]);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":367,"symbol":"testObjMiddlewareClass","kind":"method","lang":"php","code":"public function testObjMiddlewareClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('{} is not resolvable');\n\n $obj = new MiddlewareTest();\n $resolver = new CallableResolver(); // No container injected\n $resolver->resolve($obj);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":377,"symbol":"testRouteObjMiddlewareClass","kind":"method","lang":"php","code":"public function testRouteObjMiddlewareClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('{} is not resolvable');\n\n $obj = new MiddlewareTest();\n $resolver = new CallableResolver(); // No container injected\n $resolver->resolveRoute($obj);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":387,"symbol":"testMiddlewareObjMiddlewareClass","kind":"method","lang":"php","code":"public function testMiddlewareObjMiddlewareClass(): void\n {\n $obj = new MiddlewareTest();\n $request = $this->createServerRequest('/', 'GET');\n $resolver = new CallableResolver(); // No container injected\n $callableRouteMiddleware = $resolver->resolveMiddleware($obj);\n $callableRouteMiddleware($request, $this->createMock(RequestHandlerInterface::class));\n $this->assertSame(1, MiddlewareTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":397,"symbol":"testNotObjectInContainerThrowException","kind":"method","lang":"php","code":"public function testNotObjectInContainerThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('callable_service container entry is not an object');\n\n $this->containerProphecy->has('callable_service')->willReturn(true);\n $this->containerProphecy->get('callable_service')->willReturn('NOT AN OBJECT');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve('callable_service');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":411,"symbol":"testMethodNotFoundThrowException","kind":"method","lang":"php","code":"public function testMethodNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('callable_service:notFound is not resolvable');\n\n $this->containerProphecy->has('callable_service')->willReturn(true);\n $this->containerProphecy->get('callable_service')->willReturn(new CallableTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve('callable_service:notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":425,"symbol":"testRouteMethodNotFoundThrowException","kind":"method","lang":"php","code":"public function testRouteMethodNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('callable_service:notFound is not resolvable');\n\n $this->containerProphecy->has('callable_service')->willReturn(true);\n $this->containerProphecy->get('callable_service')->willReturn(new CallableTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveRoute('callable_service:notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":439,"symbol":"testMiddlewareMethodNotFoundThrowException","kind":"method","lang":"php","code":"public function testMiddlewareMethodNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('callable_service:notFound is not resolvable');\n\n $this->containerProphecy->has('callable_service')->willReturn(true);\n $this->containerProphecy->get('callable_service')->willReturn(new CallableTest());\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveMiddleware('callable_service:notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":453,"symbol":"testFunctionNotFoundThrowException","kind":"method","lang":"php","code":"public function testFunctionNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable notFound does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve('notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":464,"symbol":"testRouteFunctionNotFoundThrowException","kind":"method","lang":"php","code":"public function testRouteFunctionNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable notFound does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveRoute('notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":475,"symbol":"testMiddlewareFunctionNotFoundThrowException","kind":"method","lang":"php","code":"public function testMiddlewareFunctionNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable notFound does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveMiddleware('notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":486,"symbol":"testClassNotFoundThrowException","kind":"method","lang":"php","code":"public function testClassNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable Unknown::notFound() does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve('Unknown:notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":497,"symbol":"testRouteClassNotFoundThrowException","kind":"method","lang":"php","code":"public function testRouteClassNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable Unknown::notFound() does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveRoute('Unknown:notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":508,"symbol":"testMiddlewareClassNotFoundThrowException","kind":"method","lang":"php","code":"public function testMiddlewareClassNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable Unknown::notFound() does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveMiddleware('Unknown:notFound');\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":519,"symbol":"testCallableClassNotFoundThrowException","kind":"method","lang":"php","code":"public function testCallableClassNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable Unknown::notFound() does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolve(['Unknown', 'notFound']);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":530,"symbol":"testRouteCallableClassNotFoundThrowException","kind":"method","lang":"php","code":"public function testRouteCallableClassNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable Unknown::notFound() does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveRoute(['Unknown', 'notFound']);\n }"} {"repo":"slim","file":"tests/CallableResolverTest.php","line":541,"symbol":"testMiddlewareCallableClassNotFoundThrowException","kind":"method","lang":"php","code":"public function testMiddlewareCallableClassNotFoundThrowException(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Callable Unknown::notFound() does not exist');\n\n /** @var ContainerInterface $container */\n $container = $this->containerProphecy->reveal();\n $resolver = new CallableResolver($container);\n $resolver->resolveMiddleware(['Unknown', 'notFound']);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":32,"symbol":"AbstractErrorRendererTest","kind":"class","lang":"php","code":"class AbstractErrorRendererTest extends TestCase\n{\n public function testHTMLErrorRendererDisplaysErrorDetails()\n {\n $exception = new RuntimeException('Oops..');\n $renderer = new HtmlErrorRenderer();\n $output = $renderer->__invoke($exception, true);\n\n $this->assertMatchesRegularExpression(\n '/.*The application could not run because of the following error:.*/',\n $output\n );\n $this->assertStringContainsString('Oops..', $output);\n }\n\n public function testHTMLErrorRendererNoErrorDetails()\n {\n $exception = new RuntimeException('Oops..');\n $renderer = new HtmlErrorRenderer();\n $output = $renderer->__invoke($exception, false);\n\n $this->assertMatchesRegularExpression(\n '/.*A website error has occurred. Sorry for the temporary inconvenience.*/',\n $output\n );\n $this->assertStringNotContainsString('Oops..', $output);\n }\n\n public function testHTMLErrorRendererRenderFragmentMethod()\n {\n $exception = new Exception('Oops..', 500);\n $renderer = new HtmlErrorRenderer();\n $reflectionRenderer = new ReflectionClass(HtmlErrorRenderer"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":34,"symbol":"testHTMLErrorRendererDisplaysErrorDetails","kind":"method","lang":"php","code":"public function testHTMLErrorRendererDisplaysErrorDetails()\n {\n $exception = new RuntimeException('Oops..');\n $renderer = new HtmlErrorRenderer();\n $output = $renderer->__invoke($exception, true);\n\n $this->assertMatchesRegularExpression(\n '/.*The application could not run because of the following error:.*/',\n $output\n );\n $this->assertStringContainsString('Oops..', $output);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":47,"symbol":"testHTMLErrorRendererNoErrorDetails","kind":"method","lang":"php","code":"public function testHTMLErrorRendererNoErrorDetails()\n {\n $exception = new RuntimeException('Oops..');\n $renderer = new HtmlErrorRenderer();\n $output = $renderer->__invoke($exception, false);\n\n $this->assertMatchesRegularExpression(\n '/.*A website error has occurred. Sorry for the temporary inconvenience.*/',\n $output\n );\n $this->assertStringNotContainsString('Oops..', $output);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":60,"symbol":"testHTMLErrorRendererRenderFragmentMethod","kind":"method","lang":"php","code":"public function testHTMLErrorRendererRenderFragmentMethod()\n {\n $exception = new Exception('Oops..', 500);\n $renderer = new HtmlErrorRenderer();\n $reflectionRenderer = new ReflectionClass(HtmlErrorRenderer::class);\n\n $method = $reflectionRenderer->getMethod('renderExceptionFragment');\n $this->setAccessible($method);\n $output = $method->invoke($renderer, $exception);\n\n $this->assertMatchesRegularExpression('/.*Type:*/', $output);\n $this->assertMatchesRegularExpression('/.*Code:*/', $output);\n $this->assertMatchesRegularExpression('/.*Message*/', $output);\n $this->assertMatchesRegularExpression('/.*File*/', $output);\n $this->assertMatchesRegularExpression('/.*Line*/', $output);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":77,"symbol":"testHTMLErrorRendererRenderHttpException","kind":"method","lang":"php","code":"public function testHTMLErrorRendererRenderHttpException()\n {\n $exceptionTitle = 'title';\n $exceptionDescription = 'description';\n\n $httpExceptionProphecy = $this->prophesize(HttpException::class);\n\n $httpExceptionProphecy\n ->getTitle()\n ->willReturn($exceptionTitle)\n ->shouldBeCalledOnce();\n\n $httpExceptionProphecy\n ->getDescription()\n ->willReturn($exceptionDescription)\n ->shouldBeCalledOnce();\n\n $renderer = new HtmlErrorRenderer();\n $output = $renderer->__invoke($httpExceptionProphecy->reveal(), false);\n\n $this->assertStringContainsString($exceptionTitle, $output, 'Should contain http exception title');\n $this->assertStringContainsString($exceptionDescription, $output, 'Should contain http exception description');\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":101,"symbol":"testHTMLErrorRendererEscapesHttpException","kind":"method","lang":"php","code":"public function testHTMLErrorRendererEscapesHttpException()\n {\n $exceptionTitle = '';\n $exceptionDescription = \"\";\n\n $httpExceptionProphecy = $this->prophesize(HttpException::class);\n\n $httpExceptionProphecy\n ->getTitle()\n ->willReturn($exceptionTitle)\n ->shouldBeCalledOnce();\n\n $httpExceptionProphecy\n ->getDescription()\n ->willReturn($exceptionDescription)\n ->shouldBeCalledOnce();\n\n $renderer = new HtmlErrorRenderer();\n $output = $renderer->__invoke($httpExceptionProphecy->reveal(), false);\n\n $this->assertStringNotContainsString($exceptionTitle, $output, 'Title must not be rendered unescaped');\n $this->assertStringContainsString(\n htmlspecialchars($exceptionTitle, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'),\n $output,\n 'Title must be HTML-escaped'\n );\n\n $this->assertStringNotContainsString(\n $exceptionDescription,\n $output,\n 'Description must not be rendered unescaped'\n );\n $this->assertStringContainsString(\n "} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":140,"symbol":"testJSONErrorRendererDisplaysErrorDetails","kind":"method","lang":"php","code":"public function testJSONErrorRendererDisplaysErrorDetails()\n {\n $exception = new Exception('Oops..');\n $renderer = new JsonErrorRenderer();\n $reflectionRenderer = new ReflectionClass(JsonErrorRenderer::class);\n\n $method = $reflectionRenderer->getMethod('formatExceptionFragment');\n $this->setAccessible($method);\n\n $fragment = $method->invoke($renderer, $exception);\n $output = json_encode(json_decode($renderer->__invoke($exception, true)));\n $expectedString = json_encode(['message' => 'Slim Application Error', 'exception' => [$fragment]]);\n\n $this->assertSame($output, $expectedString);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":156,"symbol":"testJSONErrorRendererDoesNotDisplayErrorDetails","kind":"method","lang":"php","code":"public function testJSONErrorRendererDoesNotDisplayErrorDetails()\n {\n $exception = new Exception('Oops..');\n\n $renderer = new JsonErrorRenderer();\n $output = json_encode(json_decode($renderer->__invoke($exception, false)));\n\n $this->assertSame($output, json_encode(['message' => 'Slim Application Error']));\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":166,"symbol":"testJSONErrorRendererSubstitutesInvalidUtf8","kind":"method","lang":"php","code":"public function testJSONErrorRendererSubstitutesInvalidUtf8()\n {\n $exception = new Exception(\"Invalid \\xB1\\x31 UTF-8 sequence\");\n\n $renderer = new JsonErrorRenderer();\n $output = $renderer->__invoke($exception, true);\n\n $this->assertNotSame('', $output);\n $decoded = json_decode($output, true);\n $this->assertIsArray($decoded);\n $this->assertSame('Slim Application Error', $decoded['message']);\n $this->assertSame(\n \"Invalid \\u{FFFD}1 UTF-8 sequence\",\n $decoded['exception'][0]['message']\n );\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":183,"symbol":"testJSONErrorRendererDisplaysPreviousError","kind":"method","lang":"php","code":"public function testJSONErrorRendererDisplaysPreviousError()\n {\n $previousException = new Exception('Oh no!');\n $exception = new Exception('Oops..', 0, $previousException);\n\n $renderer = new JsonErrorRenderer();\n $reflectionRenderer = new ReflectionClass(JsonErrorRenderer::class);\n $method = $reflectionRenderer->getMethod('formatExceptionFragment');\n $this->setAccessible($method);\n\n $output = json_encode(json_decode($renderer->__invoke($exception, true)));\n\n $fragments = [\n $method->invoke($renderer, $exception),\n $method->invoke($renderer, $previousException),\n ];\n\n $expectedString = json_encode(['message' => 'Slim Application Error', 'exception' => $fragments]);\n\n $this->assertSame($output, $expectedString);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":205,"symbol":"testJSONErrorRendererRenderHttpException","kind":"method","lang":"php","code":"public function testJSONErrorRendererRenderHttpException()\n {\n $exceptionTitle = 'title';\n\n $httpExceptionProphecy = $this->prophesize(HttpException::class);\n\n $httpExceptionProphecy\n ->getTitle()\n ->willReturn($exceptionTitle)\n ->shouldBeCalledOnce();\n\n $renderer = new JsonErrorRenderer();\n $output = json_encode(json_decode($renderer->__invoke($httpExceptionProphecy->reveal(), false)));\n\n $this->assertSame(\n $output,\n json_encode(['message' => $exceptionTitle]),\n 'Should contain http exception title'\n );\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":227,"symbol":"testXMLErrorRendererDisplaysErrorDetails","kind":"method","lang":"php","code":"public function testXMLErrorRendererDisplaysErrorDetails()\n {\n $previousException = new RuntimeException('Oops..');\n $exception = new Exception('Ooops...', 0, $previousException);\n\n $renderer = new XmlErrorRenderer();\n\n /** @var stdClass $output */\n $output = simplexml_load_string($renderer->__invoke($exception, true));\n\n $this->assertSame((string) $output->message[0], 'Slim Application Error');\n $this->assertSame((string) $output->exception[0]->type, 'Exception');\n $this->assertSame((string) $output->exception[0]->message, 'Ooops...');\n $this->assertSame((string) $output->exception[1]->type, 'RuntimeException');\n $this->assertSame((string) $output->exception[1]->message, 'Oops..');\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":244,"symbol":"testXMLErrorRendererRenderHttpException","kind":"method","lang":"php","code":"public function testXMLErrorRendererRenderHttpException()\n {\n $exceptionTitle = 'title';\n\n $httpExceptionProphecy = $this->prophesize(HttpException::class);\n\n $httpExceptionProphecy\n ->getTitle()\n ->willReturn($exceptionTitle)\n ->shouldBeCalledOnce();\n\n $renderer = new XmlErrorRenderer();\n\n /** @var stdClass $output */\n $output = simplexml_load_string($renderer->__invoke($httpExceptionProphecy->reveal(), true));\n\n $this->assertSame((string) $output->message[0], $exceptionTitle, 'Should contain http exception title');\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":263,"symbol":"testPlainTextErrorRendererFormatFragmentMethod","kind":"method","lang":"php","code":"public function testPlainTextErrorRendererFormatFragmentMethod()\n {\n $message = 'Oops..
';\n $exception = new Exception($message, 500);\n $renderer = new PlainTextErrorRenderer();\n $reflectionRenderer = new ReflectionClass(PlainTextErrorRenderer::class);\n\n $method = $reflectionRenderer->getMethod('formatExceptionFragment');\n $this->setAccessible($method);\n $output = $method->invoke($renderer, $exception);\n $this->assertIsString($output);\n\n $this->assertMatchesRegularExpression('/.*Type:*/', $output);\n $this->assertMatchesRegularExpression('/.*Code:*/', $output);\n $this->assertMatchesRegularExpression('/.*Message*/', $output);\n $this->assertMatchesRegularExpression('/.*File*/', $output);\n $this->assertMatchesRegularExpression('/.*Line*/', $output);\n\n // ensure the renderer doesn't reformat the message\n $this->assertMatchesRegularExpression(\"/.*$message/\", $output);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":285,"symbol":"testPlainTextErrorRendererDisplaysErrorDetails","kind":"method","lang":"php","code":"public function testPlainTextErrorRendererDisplaysErrorDetails()\n {\n $previousException = new RuntimeException('Oops..');\n $exception = new Exception('Ooops...', 0, $previousException);\n\n $renderer = new PlainTextErrorRenderer();\n $output = $renderer->__invoke($exception, true);\n\n $this->assertMatchesRegularExpression('/Ooops.../', $output);\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":296,"symbol":"testPlainTextErrorRendererNotDisplaysErrorDetails","kind":"method","lang":"php","code":"public function testPlainTextErrorRendererNotDisplaysErrorDetails()\n {\n $previousException = new RuntimeException('Oops..');\n $exception = new Exception('Ooops...', 0, $previousException);\n\n $renderer = new PlainTextErrorRenderer();\n $output = $renderer->__invoke($exception, false);\n\n $this->assertSame(\"Slim Application Error\\n\", $output, 'Should show only one string');\n }"} {"repo":"slim","file":"tests/Error/AbstractErrorRendererTest.php","line":307,"symbol":"testPlainTextErrorRendererRenderHttpException","kind":"method","lang":"php","code":"public function testPlainTextErrorRendererRenderHttpException()\n {\n $exceptionTitle = 'title';\n\n $httpExceptionProphecy = $this->prophesize(HttpException::class);\n\n $httpExceptionProphecy\n ->getTitle()\n ->willReturn($exceptionTitle)\n ->shouldBeCalledOnce();\n\n $renderer = new PlainTextErrorRenderer();\n $output = $renderer->__invoke($httpExceptionProphecy->reveal(), true);\n\n $this->assertStringContainsString($exceptionTitle, $output, 'Should contain http exception title');\n }"} {"repo":"slim","file":"tests/Exception/HttpExceptionTest.php","line":18,"symbol":"HttpExceptionTest","kind":"class","lang":"php","code":"class HttpExceptionTest extends TestCase\n{\n public function testHttpExceptionRequestReponseGetterSetters()\n {\n $request = $this->createServerRequest('/');\n $exception = new HttpNotFoundException($request);\n\n $this->assertInstanceOf(ServerRequestInterface::class, $exception->getRequest());\n }\n\n public function testHttpExceptionAttributeGettersSetters()\n {\n $request = $this->createServerRequest('/');\n\n $exception = new HttpNotFoundException($request);\n $exception->setTitle('Title');\n $exception->setDescription('Description');\n\n $this->assertSame('Title', $exception->getTitle());\n $this->assertSame('Description', $exception->getDescription());\n }\n\n public function testHttpNotAllowedExceptionGetAllowedMethods()\n {\n $request = $this->createServerRequest('/');\n\n $exception = new HttpMethodNotAllowedException($request);\n $exception->setAllowedMethods(['GET']);\n $this->assertSame(['GET'], $exception->getAllowedMethods());\n $this->assertSame('Method not allowed. Must be one of: GET', $exception->getMessage());\n\n $exception = new HttpMethodNotAllowedException($requ"} {"repo":"slim","file":"tests/Exception/HttpExceptionTest.php","line":20,"symbol":"testHttpExceptionRequestReponseGetterSetters","kind":"method","lang":"php","code":"public function testHttpExceptionRequestReponseGetterSetters()\n {\n $request = $this->createServerRequest('/');\n $exception = new HttpNotFoundException($request);\n\n $this->assertInstanceOf(ServerRequestInterface::class, $exception->getRequest());\n }"} {"repo":"slim","file":"tests/Exception/HttpExceptionTest.php","line":28,"symbol":"testHttpExceptionAttributeGettersSetters","kind":"method","lang":"php","code":"public function testHttpExceptionAttributeGettersSetters()\n {\n $request = $this->createServerRequest('/');\n\n $exception = new HttpNotFoundException($request);\n $exception->setTitle('Title');\n $exception->setDescription('Description');\n\n $this->assertSame('Title', $exception->getTitle());\n $this->assertSame('Description', $exception->getDescription());\n }"} {"repo":"slim","file":"tests/Exception/HttpExceptionTest.php","line":40,"symbol":"testHttpNotAllowedExceptionGetAllowedMethods","kind":"method","lang":"php","code":"public function testHttpNotAllowedExceptionGetAllowedMethods()\n {\n $request = $this->createServerRequest('/');\n\n $exception = new HttpMethodNotAllowedException($request);\n $exception->setAllowedMethods(['GET']);\n $this->assertSame(['GET'], $exception->getAllowedMethods());\n $this->assertSame('Method not allowed. Must be one of: GET', $exception->getMessage());\n\n $exception = new HttpMethodNotAllowedException($request);\n $this->assertSame([], $exception->getAllowedMethods());\n $this->assertSame('Method not allowed.', $exception->getMessage());\n }"} {"repo":"slim","file":"tests/Exception/HttpUnauthorizedExceptionTest.php","line":16,"symbol":"HttpUnauthorizedExceptionTest","kind":"class","lang":"php","code":"class HttpUnauthorizedExceptionTest extends TestCase\n{\n public function testHttpUnauthorizedException()\n {\n $request = $this->createServerRequest('/');\n $exception = new HttpUnauthorizedException($request);\n\n $this->assertInstanceOf(HttpUnauthorizedException::class, $exception);\n }\n\n public function testHttpUnauthorizedExceptionWithMessage()\n {\n $request = $this->createServerRequest('/');\n $exception = new HttpUnauthorizedException($request, 'Hello World');\n\n $this->assertSame('Hello World', $exception->getMessage());\n }\n}"} {"repo":"slim","file":"tests/Exception/HttpUnauthorizedExceptionTest.php","line":18,"symbol":"testHttpUnauthorizedException","kind":"method","lang":"php","code":"public function testHttpUnauthorizedException()\n {\n $request = $this->createServerRequest('/');\n $exception = new HttpUnauthorizedException($request);\n\n $this->assertInstanceOf(HttpUnauthorizedException::class, $exception);\n }"} {"repo":"slim","file":"tests/Exception/HttpUnauthorizedExceptionTest.php","line":26,"symbol":"testHttpUnauthorizedExceptionWithMessage","kind":"method","lang":"php","code":"public function testHttpUnauthorizedExceptionWithMessage()\n {\n $request = $this->createServerRequest('/');\n $exception = new HttpUnauthorizedException($request, 'Hello World');\n\n $this->assertSame('Hello World', $exception->getMessage());\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":45,"symbol":"AppFactoryTest","kind":"class","lang":"php","code":"class AppFactoryTest extends TestCase\n{\n protected function tearDown(): void\n {\n $reflectionClass = new ReflectionClass(SlimHttpPsr17Factory::class);\n $reflectionClass->setStaticPropertyValue('responseFactoryClass', DecoratedResponseFactory::class);\n }\n\n public static function provideImplementations()\n {\n return [\n [SlimPsr17Factory::class, SlimResponseFactory::class],\n [HttpSoftPsr17Factory::class, HttpSoftResponseFactory::class],\n [NyholmPsr17Factory::class, Psr17Factory::class],\n [GuzzlePsr17Factory::class, HttpFactory::class],\n [LaminasDiactorosPsr17Factory::class, LaminasDiactorosResponseFactory::class],\n ];\n }\n\n /**\n * @dataProvider provideImplementations\n * @param string $psr17factory\n * @param string $expectedResponseFactoryClass\n */\n #[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideImplementations')]\n public function testCreateAppWithAllImplementations(string $psr17factory, string $expectedResponseFactoryClass)\n {\n Psr17FactoryProvider::setFactories([$psr17factory]);\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":47,"symbol":"tearDown","kind":"method","lang":"php","code":"protected function tearDown(): void\n {\n $reflectionClass = new ReflectionClass(SlimHttpPsr17Factory::class);\n $reflectionClass->setStaticPropertyValue('responseFactoryClass', DecoratedResponseFactory::class);\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":53,"symbol":"provideImplementations","kind":"method","lang":"php","code":"public static function provideImplementations()\n {\n return [\n [SlimPsr17Factory::class, SlimResponseFactory::class],\n [HttpSoftPsr17Factory::class, HttpSoftResponseFactory::class],\n [NyholmPsr17Factory::class, Psr17Factory::class],\n [GuzzlePsr17Factory::class, HttpFactory::class],\n [LaminasDiactorosPsr17Factory::class, LaminasDiactorosResponseFactory::class],\n ];\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":69,"symbol":"testCreateAppWithAllImplementations","kind":"method","lang":"php","doc":"@dataProvider provideImplementations @param string $psr17factory @param string $expectedResponseFactoryClass","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideImplementations')]\n public function testCreateAppWithAllImplementations(string $psr17factory, string $expectedResponseFactoryClass)\n {\n Psr17FactoryProvider::setFactories([$psr17factory]);\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n $app = AppFactory::create();\n\n $routeCollector = $app->getRouteCollector();\n\n $responseFactoryProperty = new ReflectionProperty(RouteCollector::class, 'responseFactory');\n $this->setAccessible($responseFactoryProperty);\n\n $responseFactory = $responseFactoryProperty->getValue($routeCollector);\n\n $this->assertInstanceOf($expectedResponseFactoryClass, $responseFactory);\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":87,"symbol":"testDetermineResponseFactoryReturnsDecoratedFactory","kind":"method","lang":"php","code":"public function testDetermineResponseFactoryReturnsDecoratedFactory()\n {\n Psr17FactoryProvider::setFactories([SlimPsr17Factory::class]);\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(true);\n\n $app = AppFactory::create();\n\n $this->assertInstanceOf(DecoratedResponseFactory::class, $app->getResponseFactory());\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":97,"symbol":"testDetermineResponseFactoryThrowsRuntimeExceptionIfDecoratedNotInstanceOfResponseInterface","kind":"method","lang":"php","code":"public function testDetermineResponseFactoryThrowsRuntimeExceptionIfDecoratedNotInstanceOfResponseInterface()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage(\n 'Slim\\\\Factory\\\\Psr17\\\\SlimHttpPsr17Factory could not instantiate a decorated response factory.'\n );\n\n $reflectionClass = new ReflectionClass(SlimHttpPsr17Factory::class);\n $reflectionClass->setStaticPropertyValue('responseFactoryClass', SlimHttpPsr17Factory::class);\n\n Psr17FactoryProvider::setFactories([SlimPsr17Factory::class]);\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(true);\n\n AppFactory::create();\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":116,"symbol":"testDetermineResponseFactoryThrowsRuntimeException","kind":"method","lang":"php","doc":"@runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testDetermineResponseFactoryThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n\n Psr17FactoryProvider::setFactories([]);\n AppFactory::create();\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":125,"symbol":"testSetPsr17FactoryProvider","kind":"method","lang":"php","code":"public function testSetPsr17FactoryProvider()\n {\n $psr17FactoryProvider = new Psr17FactoryProvider();\n $psr17FactoryProvider::setFactories([SlimPsr17Factory::class]);\n\n AppFactory::setPsr17FactoryProvider($psr17FactoryProvider);\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n $this->assertInstanceOf(SlimResponseFactory::class, AppFactory::determineResponseFactory());\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":139,"symbol":"testResponseFactoryIsStillReturnedIfStreamFactoryIsNotAvailable","kind":"method","lang":"php","doc":"@runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testResponseFactoryIsStillReturnedIfStreamFactoryIsNotAvailable()\n {\n Psr17FactoryProvider::setFactories([MockPsr17FactoryWithoutStreamFactory::class]);\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(true);\n\n $app = AppFactory::create();\n\n $this->assertInstanceOf(SlimResponseFactory::class, $app->getResponseFactory());\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":153,"symbol":"testAppIsCreatedWithInstancesFromSetters","kind":"method","lang":"php","doc":"@runInSeparateProcess - AppFactory::setResponseFactory breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testAppIsCreatedWithInstancesFromSetters()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeParserProphecy = $this->prophesize(RouteParserInterface::class);\n $routeResolverProphecy = $this->prophesize(RouteResolverInterface::class);\n $middlewareDispatcherProphecy = $this->prophesize(MiddlewareDispatcherInterface::class);\n\n $routeCollectorProphecy->getRouteParser()->willReturn($routeParserProphecy);\n\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n AppFactory::setResponseFactory($responseFactoryProphecy->reveal());\n AppFactory::setContainer($containerProphecy->reveal());\n AppFactory::setCallableResolver($callableResolverProphecy->reveal());\n AppFactory::setRouteCollector($routeCollectorProphecy->reveal());\n AppFactory::setRouteResolve"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":211,"symbol":"testAppIsCreatedWithInjectedInstancesFromFunctionArguments","kind":"method","lang":"php","doc":"@runInSeparateProcess - AppFactory::create saves $responseFactory into static::$responseFactory, this breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testAppIsCreatedWithInjectedInstancesFromFunctionArguments()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeParserProphecy = $this->prophesize(RouteParserInterface::class);\n $routeResolverProphecy = $this->prophesize(RouteResolverInterface::class);\n\n $routeCollectorProphecy->getRouteParser()->willReturn($routeParserProphecy->reveal());\n\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n $app = AppFactory::create(\n $responseFactoryProphecy->reveal(),\n $containerProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $routeCollectorProphecy->reveal(),\n $routeResolverProphecy->reveal()\n );\n\n $this->assertSame(\n $responseFactoryProphecy->reveal(),\n $app->getResponseFactory()\n "} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":262,"symbol":"testResponseAndStreamFactoryIsBeingInjectedInDecoratedResponseFactory","kind":"method","lang":"php","doc":"@runInSeparateProcess - AppFactory::setResponseFactory breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testResponseAndStreamFactoryIsBeingInjectedInDecoratedResponseFactory()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse(200, '')\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $streamFactoryProphecy = $this->prophesize(StreamFactoryInterface::class);\n\n AppFactory::setResponseFactory($responseFactoryProphecy->reveal());\n AppFactory::setStreamFactory($streamFactoryProphecy->reveal());\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(true);\n\n $app = AppFactory::create();\n\n $responseFactory = $app->getResponseFactory();\n $response = $responseFactory->createResponse();\n\n $streamFactoryProperty = new ReflectionProperty(DecoratedResponse::class, 'streamFactory');\n $this->setAccessible($streamFactoryProperty);\n\n $this->assertSame($streamFactoryProphecy->reveal(), $streamFactoryProperty->getValue($response));\n }"} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":290,"symbol":"testCreateAppWithContainerUsesContainerDependenciesWhenPresent","kind":"method","lang":"php","code":"public function testCreateAppWithContainerUsesContainerDependenciesWhenPresent()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $routeResolverProphecy = $this->prophesize(RouteResolverInterface::class);\n $routeParserProphecy = $this->prophesize(RouteParserInterface::class);\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->getRouteParser()\n ->willReturn($routeParserProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $middlewareDispatcherProphecy = $this->prophesize(MiddlewareDispatcherInterface::class);\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $containerProphecy\n ->has(ResponseFactoryInterface::class)\n ->willReturn(true)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->get(ResponseFactoryInterface::class)\n ->willReturn($responseFactoryProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy\n "} {"repo":"slim","file":"tests/Factory/AppFactoryTest.php","line":368,"symbol":"testCreateAppWithEmptyContainer","kind":"method","lang":"php","code":"public function testCreateAppWithEmptyContainer()\n {\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $containerProphecy\n ->has(ResponseFactoryInterface::class)\n ->willReturn(false)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->has(CallableResolverInterface::class)\n ->willReturn(false)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->has(RouteCollectorInterface::class)\n ->willReturn(false)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->has(RouteResolverInterface::class)\n ->willReturn(false)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->has(MiddlewareDispatcherInterface::class)\n ->willReturn(false)\n ->shouldBeCalledOnce();\n\n AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n AppFactory::createFromContainer($containerProphecy->reveal());\n }"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryProviderTest.php","line":16,"symbol":"Psr17FactoryProviderTest","kind":"class","lang":"php","code":"class Psr17FactoryProviderTest extends TestCase\n{\n /**\n * @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests\n */\n #[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testGetSetFactories()\n {\n Psr17FactoryProvider::setFactories([]);\n\n $this->assertSame([], Psr17FactoryProvider::getFactories());\n }\n\n\n /**\n * @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests\n */\n #[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testAddFactory()\n {\n Psr17FactoryProvider::setFactories(['Factory 1']);\n Psr17FactoryProvider::addFactory('Factory 2');\n\n $this->assertSame(['Factory 2', 'Factory 1'], Psr17FactoryProvider::getFactories());\n }\n}"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryProviderTest.php","line":21,"symbol":"testGetSetFactories","kind":"method","lang":"php","doc":"@runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testGetSetFactories()\n {\n Psr17FactoryProvider::setFactories([]);\n\n $this->assertSame([], Psr17FactoryProvider::getFactories());\n }"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryProviderTest.php","line":33,"symbol":"testAddFactory","kind":"method","lang":"php","doc":"@runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testAddFactory()\n {\n Psr17FactoryProvider::setFactories(['Factory 1']);\n Psr17FactoryProvider::addFactory('Factory 2');\n\n $this->assertSame(['Factory 2', 'Factory 1'], Psr17FactoryProvider::getFactories());\n }"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryTest.php","line":17,"symbol":"Psr17FactoryTest","kind":"class","lang":"php","code":"class Psr17FactoryTest extends TestCase\n{\n public function testGetResponseFactoryThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\MockPsr17Factory could not instantiate a response factory.');\n\n MockPsr17Factory::getResponseFactory();\n }\n\n public function testGetStreamFactoryThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\MockPsr17Factory could not instantiate a stream factory.');\n\n MockPsr17Factory::getStreamFactory();\n }\n\n public function testGetServerRequestCreatorThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\MockPsr17Factory' .\n ' could not instantiate a server request creator.');\n\n MockPsr17Factory::getServerRequestCreator();\n }\n}"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryTest.php","line":19,"symbol":"testGetResponseFactoryThrowsRuntimeException","kind":"method","lang":"php","code":"public function testGetResponseFactoryThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\MockPsr17Factory could not instantiate a response factory.');\n\n MockPsr17Factory::getResponseFactory();\n }"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryTest.php","line":27,"symbol":"testGetStreamFactoryThrowsRuntimeException","kind":"method","lang":"php","code":"public function testGetStreamFactoryThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\MockPsr17Factory could not instantiate a stream factory.');\n\n MockPsr17Factory::getStreamFactory();\n }"} {"repo":"slim","file":"tests/Factory/Psr17/Psr17FactoryTest.php","line":35,"symbol":"testGetServerRequestCreatorThrowsRuntimeException","kind":"method","lang":"php","code":"public function testGetServerRequestCreatorThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Slim\\\\Tests\\\\Mocks\\\\MockPsr17Factory' .\n ' could not instantiate a server request creator.');\n\n MockPsr17Factory::getServerRequestCreator();\n }"} {"repo":"slim","file":"tests/Factory/Psr17/SlimHttpServerRequestCreatorTest.php","line":23,"symbol":"SlimHttpServerRequestCreatorTest","kind":"class","lang":"php","code":"class SlimHttpServerRequestCreatorTest extends TestCase\n{\n /**\n * We need to reset the static property of SlimHttpServerRequestCreator back to its original value\n * Otherwise other tests will fail\n */\n public function tearDown(): void\n {\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n\n $slimHttpServerRequestCreator = new SlimHttpServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $serverRequestDecoratorClassProperty = new ReflectionProperty(\n SlimHttpServerRequestCreator::class,\n 'serverRequestDecoratorClass'\n );\n $this->setAccessible($serverRequestDecoratorClassProperty);\n $serverRequestDecoratorClassProperty->setValue($slimHttpServerRequestCreator, ServerRequest::class);\n }\n\n public function testCreateServerRequestFromGlobals()\n {\n $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);\n\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n\n $serverRequestCreatorProphecy\n ->createServerRequestFromGlobals()\n ->willReturn($serverRequestP"} {"repo":"slim","file":"tests/Factory/Psr17/SlimHttpServerRequestCreatorTest.php","line":29,"symbol":"tearDown","kind":"method","lang":"php","doc":"We need to reset the static property of SlimHttpServerRequestCreator back to its original value Otherwise other tests will fail","code":"public function tearDown(): void\n {\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n\n $slimHttpServerRequestCreator = new SlimHttpServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $serverRequestDecoratorClassProperty = new ReflectionProperty(\n SlimHttpServerRequestCreator::class,\n 'serverRequestDecoratorClass'\n );\n $this->setAccessible($serverRequestDecoratorClassProperty);\n $serverRequestDecoratorClassProperty->setValue($slimHttpServerRequestCreator, ServerRequest::class);\n }"} {"repo":"slim","file":"tests/Factory/Psr17/SlimHttpServerRequestCreatorTest.php","line":43,"symbol":"testCreateServerRequestFromGlobals","kind":"method","lang":"php","code":"public function testCreateServerRequestFromGlobals()\n {\n $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);\n\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n\n $serverRequestCreatorProphecy\n ->createServerRequestFromGlobals()\n ->willReturn($serverRequestProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $slimHttpServerRequestCreator = new SlimHttpServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $this->assertInstanceOf(ServerRequest::class, $slimHttpServerRequestCreator->createServerRequestFromGlobals());\n }"} {"repo":"slim","file":"tests/Factory/Psr17/SlimHttpServerRequestCreatorTest.php","line":59,"symbol":"testCreateServerRequestFromGlobalsThrowsRuntimeException","kind":"method","lang":"php","code":"public function testCreateServerRequestFromGlobalsThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('The Slim-Http ServerRequest decorator is not available.');\n\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n\n $slimHttpServerRequestCreator = new SlimHttpServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $serverRequestDecoratorClassProperty = new ReflectionProperty(\n SlimHttpServerRequestCreator::class,\n 'serverRequestDecoratorClass'\n );\n $this->setAccessible($serverRequestDecoratorClassProperty);\n $serverRequestDecoratorClassProperty->setValue($slimHttpServerRequestCreator, '');\n\n $slimHttpServerRequestCreator->createServerRequestFromGlobals();\n }"} {"repo":"slim","file":"tests/Factory/Psr17/SlimHttpServerRequestCreatorTest.php","line":78,"symbol":"testCreateServerRequestFromGlobalsThrowsRuntimeExceptionIfNotInstanceOfServerRequestInterface","kind":"method","lang":"php","code":"public function testCreateServerRequestFromGlobalsThrowsRuntimeExceptionIfNotInstanceOfServerRequestInterface()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage(\n 'Slim\\\\Factory\\\\Psr17\\\\SlimHttpServerRequestCreator could not instantiate a decorated server request.'\n );\n\n $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);\n\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n $serverRequestCreatorProphecy\n ->createServerRequestFromGlobals()\n ->willReturn($serverRequestProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $slimHttpServerRequestCreator = new SlimHttpServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $reflectionClass = new ReflectionClass(SlimHttpServerRequestCreator::class);\n $reflectionClass->setStaticPropertyValue('serverRequestDecoratorClass', stdClass::class);\n\n $slimHttpServerRequestCreator->createServerRequestFromGlobals();\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":32,"symbol":"ServerRequestCreatorFactoryTest","kind":"class","lang":"php","code":"class ServerRequestCreatorFactoryTest extends TestCase\n{\n public static function provideImplementations()\n {\n return [\n [SlimPsr17Factory::class, SlimServerRequest::class],\n [HttpSoftPsr17Factory::class, HttpSoftServerRequest::class],\n [NyholmPsr17Factory::class, NyholmServerRequest::class],\n [GuzzlePsr17Factory::class, GuzzleServerRequest::class],\n [LaminasDiactorosPsr17Factory::class, LaminasDiactorosServerRequest::class],\n ];\n }\n\n /**\n * @dataProvider provideImplementations\n * @param string $psr17factory\n * @param string $expectedServerRequestClass\n */\n #[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideImplementations')]\n public function testCreateAppWithAllImplementations(string $psr17factory, string $expectedServerRequestClass)\n {\n Psr17FactoryProvider::setFactories([$psr17factory]);\n ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n $serverRequest = $serverRequestCreator->createServerRequestFromGlobals();\n\n $this->assertInstanceOf($expectedSer"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":34,"symbol":"provideImplementations","kind":"method","lang":"php","code":"public static function provideImplementations()\n {\n return [\n [SlimPsr17Factory::class, SlimServerRequest::class],\n [HttpSoftPsr17Factory::class, HttpSoftServerRequest::class],\n [NyholmPsr17Factory::class, NyholmServerRequest::class],\n [GuzzlePsr17Factory::class, GuzzleServerRequest::class],\n [LaminasDiactorosPsr17Factory::class, LaminasDiactorosServerRequest::class],\n ];\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":50,"symbol":"testCreateAppWithAllImplementations","kind":"method","lang":"php","doc":"@dataProvider provideImplementations @param string $psr17factory @param string $expectedServerRequestClass","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideImplementations')]\n public function testCreateAppWithAllImplementations(string $psr17factory, string $expectedServerRequestClass)\n {\n Psr17FactoryProvider::setFactories([$psr17factory]);\n ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n $serverRequest = $serverRequestCreator->createServerRequestFromGlobals();\n\n $this->assertInstanceOf($expectedServerRequestClass, $serverRequest);\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":62,"symbol":"testDetermineServerRequestCreatorReturnsDecoratedServerRequestCreator","kind":"method","lang":"php","code":"public function testDetermineServerRequestCreatorReturnsDecoratedServerRequestCreator()\n {\n Psr17FactoryProvider::setFactories([SlimPsr17Factory::class]);\n ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(true);\n\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n\n $this->assertInstanceOf(SlimHttpServerRequestCreator::class, $serverRequestCreator);\n $this->assertInstanceOf(ServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":76,"symbol":"testDetermineServerRequestCreatorThrowsRuntimeException","kind":"method","lang":"php","doc":"@runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testDetermineServerRequestCreatorThrowsRuntimeException()\n {\n $this->expectException(RuntimeException::class);\n\n Psr17FactoryProvider::setFactories([]);\n ServerRequestCreatorFactory::create();\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":85,"symbol":"testSetPsr17FactoryProvider","kind":"method","lang":"php","code":"public function testSetPsr17FactoryProvider()\n {\n $psr17FactoryProvider = new Psr17FactoryProvider();\n $psr17FactoryProvider::setFactories([SlimPsr17Factory::class]);\n\n ServerRequestCreatorFactory::setPsr17FactoryProvider($psr17FactoryProvider);\n ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n\n $this->assertInstanceOf(SlimServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":101,"symbol":"testSetServerRequestCreatorWithoutDecorators","kind":"method","lang":"php","doc":"@runInSeparateProcess - ServerRequestCreatorFactory::setServerRequestCreator breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testSetServerRequestCreatorWithoutDecorators()\n {\n ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);\n $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);\n\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n $serverRequestCreatorProphecy\n ->createServerRequestFromGlobals()\n ->willReturn($serverRequestProphecy->reveal())\n ->shouldBeCalledOnce();\n\n ServerRequestCreatorFactory::setServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n\n $this->assertSame($serverRequestProphecy->reveal(), $serverRequestCreator->createServerRequestFromGlobals());\n }"} {"repo":"slim","file":"tests/Factory/ServerRequestCreatorFactoryTest.php","line":123,"symbol":"testSetServerRequestCreatorWithDecorators","kind":"method","lang":"php","doc":"@runInSeparateProcess - ServerRequestCreatorFactory::setServerRequestCreator breaks other tests","code":"#[\\PHPUnit\\Framework\\Attributes\\RunInSeparateProcess]\n public function testSetServerRequestCreatorWithDecorators()\n {\n ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(true);\n $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);\n\n $serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);\n $serverRequestCreatorProphecy\n ->createServerRequestFromGlobals()\n ->willReturn($serverRequestProphecy->reveal())\n ->shouldBeCalledOnce();\n\n ServerRequestCreatorFactory::setServerRequestCreator($serverRequestCreatorProphecy->reveal());\n\n $serverRequestCreator = ServerRequestCreatorFactory::create();\n\n $this->assertInstanceOf(ServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":31,"symbol":"ErrorHandlerTest","kind":"class","lang":"php","code":"class ErrorHandlerTest extends TestCase\n{\n private function getMockLogger(): LoggerInterface\n {\n return $this->createMock(LoggerInterface::class);\n }\n\n public function testDetermineRenderer()\n {\n $handler = $this->createMock(ErrorHandler::class);\n $class = new ReflectionClass(ErrorHandler::class);\n\n $callableResolverProperty = $class->getProperty('callableResolver');\n $this->setAccessible($callableResolverProperty);\n $callableResolverProperty->setValue($handler, $this->getCallableResolver());\n\n $reflectionProperty = $class->getProperty('contentType');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, 'application/json');\n\n $method = $class->getMethod('determineRenderer');\n $this->setAccessible($method);\n\n $renderer = $method->invoke($handler);\n $this->assertIsCallable($renderer);\n $this->assertInstanceOf(JsonErrorRenderer::class, $renderer[0]);\n\n $reflectionProperty->setValue($handler, 'application/xml');\n $renderer = $method->invoke($handler);\n $this->assertIsCallable($renderer);\n $this->assertInstanceOf(Xml"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":33,"symbol":"getMockLogger","kind":"method","lang":"php","code":"private function getMockLogger(): LoggerInterface\n {\n return $this->createMock(LoggerInterface::class);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":38,"symbol":"testDetermineRenderer","kind":"method","lang":"php","code":"public function testDetermineRenderer()\n {\n $handler = $this->createMock(ErrorHandler::class);\n $class = new ReflectionClass(ErrorHandler::class);\n\n $callableResolverProperty = $class->getProperty('callableResolver');\n $this->setAccessible($callableResolverProperty);\n $callableResolverProperty->setValue($handler, $this->getCallableResolver());\n\n $reflectionProperty = $class->getProperty('contentType');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, 'application/json');\n\n $method = $class->getMethod('determineRenderer');\n $this->setAccessible($method);\n\n $renderer = $method->invoke($handler);\n $this->assertIsCallable($renderer);\n $this->assertInstanceOf(JsonErrorRenderer::class, $renderer[0]);\n\n $reflectionProperty->setValue($handler, 'application/xml');\n $renderer = $method->invoke($handler);\n $this->assertIsCallable($renderer);\n $this->assertInstanceOf(XmlErrorRenderer::class, $renderer[0]);\n\n $reflectionProperty->setValue($handler, 'text/plain');\n $renderer = $method->invoke($handler);\n $this->assertIs"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":75,"symbol":"testDetermineStatusCode","kind":"method","lang":"php","code":"public function testDetermineStatusCode()\n {\n $request = $this->createServerRequest('/');\n $handler = $this->createMock(ErrorHandler::class);\n $class = new ReflectionClass(ErrorHandler::class);\n\n $reflectionProperty = $class->getProperty('responseFactory');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $this->getResponseFactory());\n\n $reflectionProperty = $class->getProperty('exception');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, new HttpNotFoundException($request));\n\n $method = $class->getMethod('determineStatusCode');\n $this->setAccessible($method);\n\n $statusCode = $method->invoke($handler);\n $this->assertSame($statusCode, 404);\n\n $reflectionProperty->setValue($handler, new MockCustomException());\n\n $statusCode = $method->invoke($handler);\n $this->assertSame($statusCode, 500);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":104,"symbol":"testForceContentType","kind":"method","lang":"php","doc":"Test if we can force the content type of all error handler responses.","code":"public function testForceContentType()\n {\n $request = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'text/plain,text/xml');\n\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $handler->forceContentType('application/json');\n\n $exception = new HttpNotFoundException($request);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($request, $exception, false, false, false);\n\n $this->assertSame(['application/json'], $response->getHeader('Content-Type'));\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":125,"symbol":"testContentTypeIsNegotiatedOnEachRequest","kind":"method","lang":"php","doc":"Test that the content type is negotiated from the Accept header on each request instead of being cached from the first invocation.","code":"public function testContentTypeIsNegotiatedOnEachRequest()\n {\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n\n $jsonRequest = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'application/json');\n\n $htmlRequest = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'text/html');\n\n $exception = new HttpNotFoundException($jsonRequest);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($jsonRequest, $exception, false, false, false);\n $this->assertSame(['application/json'], $response->getHeader('Content-Type'));\n\n $exception = new HttpNotFoundException($htmlRequest);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($htmlRequest, $exception, false, false, false);\n $this->assertSame(['text/html'], $response->getHeader('Content-Type'));\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":153,"symbol":"testForcedContentTypeWinsOverSubsequentNegotiation","kind":"method","lang":"php","doc":"Test that a forced content type still wins over per-request negotiation.","code":"public function testForcedContentTypeWinsOverSubsequentNegotiation()\n {\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $handler->forceContentType('application/json');\n\n $jsonRequest = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'application/json');\n\n $xmlRequest = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'application/xml');\n\n $exception = new HttpNotFoundException($jsonRequest);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($jsonRequest, $exception, false, false, false);\n $this->assertSame(['application/json'], $response->getHeader('Content-Type'));\n\n $exception = new HttpNotFoundException($xmlRequest);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($xmlRequest, $exception, false, false, false);\n $this->assertSame(['application/json'], $response->getHeader('Content-Type'));\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":182,"symbol":"testForceContentTypeNullRestoresNegotiation","kind":"method","lang":"php","doc":"Test that forceContentType(null) restores Accept-header negotiation.","code":"public function testForceContentTypeNullRestoresNegotiation()\n {\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $handler->forceContentType('application/json');\n\n $xmlRequest = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'application/xml');\n\n $htmlRequest = $this\n ->createServerRequest('/not-defined', 'GET')\n ->withHeader('Accept', 'text/html');\n\n $exception = new HttpNotFoundException($xmlRequest);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($xmlRequest, $exception, false, false, false);\n $this->assertSame(['application/json'], $response->getHeader('Content-Type'));\n\n $handler->forceContentType(null);\n\n $exception = new HttpNotFoundException($xmlRequest);\n\n /** @var ResponseInterface $response */\n $response = $handler->__invoke($xmlRequest, $exception, false, false, false);\n $this->assertSame(['application/xml'], $response->getHeader('Content-Type'));\n\n $exception = new HttpNotFoundException($htmlRequest);\n\n /** @var ResponseInte"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":216,"symbol":"testHalfValidContentType","kind":"method","lang":"php","code":"public function testHalfValidContentType()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Content-Type', 'unknown/json+');\n\n $handler = $this->createMock(ErrorHandler::class);\n $newErrorRenderers = [\n 'application/xml' => XmlErrorRenderer::class,\n 'text/xml' => XmlErrorRenderer::class,\n 'text/html' => HtmlErrorRenderer::class,\n ];\n\n $class = new ReflectionClass(ErrorHandler::class);\n\n $reflectionProperty = $class->getProperty('responseFactory');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $this->getResponseFactory());\n\n $reflectionProperty = $class->getProperty('errorRenderers');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $newErrorRenderers);\n\n $method = $class->getMethod('determineContentType');\n $this->setAccessible($method);\n\n $contentType = $method->invoke($handler, $request);\n\n $this->assertNull($contentType);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":247,"symbol":"testDetermineContentTypeTextPlainMultiAcceptHeader","kind":"method","lang":"php","code":"public function testDetermineContentTypeTextPlainMultiAcceptHeader()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Content-Type', 'text/plain')\n ->withHeader('Accept', 'text/plain,text/xml');\n\n $handler = $this->createMock(ErrorHandler::class);\n\n $errorRenderers = [\n 'text/plain' => PlainTextErrorRenderer::class,\n 'text/xml' => XmlErrorRenderer::class,\n ];\n\n $class = new ReflectionClass(ErrorHandler::class);\n\n $reflectionProperty = $class->getProperty('responseFactory');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $this->getResponseFactory());\n\n $reflectionProperty = $class->getProperty('errorRenderers');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $errorRenderers);\n\n $method = $class->getMethod('determineContentType');\n $this->setAccessible($method);\n\n $contentType = $method->invoke($handler, $request);\n\n $this->assertSame('text/xml', $contentType);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":279,"symbol":"testDetermineContentTypeApplicationJsonOrXml","kind":"method","lang":"php","code":"public function testDetermineContentTypeApplicationJsonOrXml()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Content-Type', 'text/json')\n ->withHeader('Accept', 'application/xhtml+xml');\n\n $handler = $this->createMock(ErrorHandler::class);\n\n $errorRenderers = [\n 'application/xml' => XmlErrorRenderer::class\n ];\n\n $class = new ReflectionClass(ErrorHandler::class);\n\n $reflectionProperty = $class->getProperty('responseFactory');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $this->getResponseFactory());\n\n $reflectionProperty = $class->getProperty('errorRenderers');\n $this->setAccessible($reflectionProperty);\n $reflectionProperty->setValue($handler, $errorRenderers);\n\n $method = $class->getMethod('determineContentType');\n $this->setAccessible($method);\n\n $contentType = $method->invoke($handler, $request);\n\n $this->assertSame('application/xml', $contentType);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":314,"symbol":"testAcceptableMediaTypeIsNotFirstInList","kind":"method","lang":"php","doc":"Ensure that an acceptable media-type is found in the Accept header even if it's not the first in the list.","code":"public function testAcceptableMediaTypeIsNotFirstInList()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Accept', 'text/plain,text/html');\n\n // provide access to the determineContentType() as it's a protected method\n $class = new ReflectionClass(ErrorHandler::class);\n $method = $class->getMethod('determineContentType');\n $this->setAccessible($method);\n\n // use a mock object here as ErrorHandler cannot be directly instantiated\n $handler = $this->createMock(ErrorHandler::class);\n\n // call determineContentType()\n $return = $method->invoke($handler, $request);\n\n $this->assertSame('text/html', $return);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":334,"symbol":"testRegisterErrorRenderer","kind":"method","lang":"php","code":"public function testRegisterErrorRenderer()\n {\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $handler->registerErrorRenderer('application/slim', PlainTextErrorRenderer::class);\n\n $reflectionClass = new ReflectionClass(ErrorHandler::class);\n $reflectionProperty = $reflectionClass->getProperty('errorRenderers');\n $this->setAccessible($reflectionProperty);\n $errorRenderers = $reflectionProperty->getValue($handler);\n\n $this->assertArrayHasKey('application/slim', $errorRenderers);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":347,"symbol":"testSetDefaultErrorRenderer","kind":"method","lang":"php","code":"public function testSetDefaultErrorRenderer()\n {\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $handler->setDefaultErrorRenderer('text/plain', PlainTextErrorRenderer::class);\n\n $reflectionClass = new ReflectionClass(ErrorHandler::class);\n $reflectionProperty = $reflectionClass->getProperty('defaultErrorRenderer');\n $this->setAccessible($reflectionProperty);\n $defaultErrorRenderer = $reflectionProperty->getValue($handler);\n\n $defaultErrorRendererContentTypeProperty = $reflectionClass->getProperty('defaultErrorRendererContentType');\n $this->setAccessible($defaultErrorRendererContentTypeProperty);\n $defaultErrorRendererContentType = $defaultErrorRendererContentTypeProperty->getValue($handler);\n\n $this->assertSame(PlainTextErrorRenderer::class, $defaultErrorRenderer);\n $this->assertSame('text/plain', $defaultErrorRendererContentType);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":365,"symbol":"testOptions","kind":"method","lang":"php","code":"public function testOptions()\n {\n $request = $this->createServerRequest('/', 'OPTIONS');\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $exception = new HttpMethodNotAllowedException($request);\n $exception->setAllowedMethods(['POST', 'PUT']);\n\n /** @var ResponseInterface $res */\n $res = $handler->__invoke($request, $exception, true, false, true);\n\n $this->assertSame(200, $res->getStatusCode());\n $this->assertTrue($res->hasHeader('Allow'));\n $this->assertSame('POST, PUT', $res->getHeaderLine('Allow'));\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":380,"symbol":"testWriteToErrorLog","kind":"method","lang":"php","code":"public function testWriteToErrorLog()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Accept', 'application/json');\n\n $logger = $this->getMockLogger();\n\n $handler = new ErrorHandler(\n $this->getCallableResolver(),\n $this->getResponseFactory(),\n $logger\n );\n\n $logger->expects(self::once())\n ->method('error')\n ->willReturnCallback(static function (string $error) {\n self::assertStringNotContainsString(\n 'set \"displayErrorDetails\" to true in the ErrorHandler constructor',\n $error\n );\n });\n\n $exception = new HttpNotFoundException($request);\n $handler->__invoke($request, $exception, true, true, true);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":407,"symbol":"testWriteToErrorLogShowTip","kind":"method","lang":"php","code":"public function testWriteToErrorLogShowTip()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Accept', 'application/json');\n\n $logger = $this->getMockLogger();\n\n $handler = new ErrorHandler(\n $this->getCallableResolver(),\n $this->getResponseFactory(),\n $logger\n );\n\n $logger->expects(self::once())\n ->method('error')\n ->willReturnCallback(static function (string $error) {\n self::assertStringContainsString(\n 'set \"displayErrorDetails\" to true in the ErrorHandler constructor',\n $error\n );\n });\n\n $exception = new HttpNotFoundException($request);\n $handler->__invoke($request, $exception, false, true, true);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":434,"symbol":"testWriteToErrorLogDoesNotShowTipIfErrorLogRendererIsNotPlainText","kind":"method","lang":"php","code":"public function testWriteToErrorLogDoesNotShowTipIfErrorLogRendererIsNotPlainText()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Accept', 'application/json');\n\n $logger = $this->getMockLogger();\n\n $handler = new ErrorHandler(\n $this->getCallableResolver(),\n $this->getResponseFactory(),\n $logger\n );\n\n $handler->setLogErrorRenderer(HtmlErrorRenderer::class);\n\n $logger->expects(self::once())\n ->method('error')\n ->willReturnCallback(static function (string $error) {\n self::assertStringNotContainsString(\n 'set \"displayErrorDetails\" to true in the ErrorHandler constructor',\n $error\n );\n });\n\n $exception = new HttpNotFoundException($request);\n $handler->__invoke($request, $exception, false, true, true);\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":463,"symbol":"testDefaultErrorRenderer","kind":"method","lang":"php","code":"public function testDefaultErrorRenderer()\n {\n $request = $this\n ->createServerRequest('/', 'GET')\n ->withHeader('Accept', 'application/unknown');\n\n $handler = new ErrorHandler($this->getCallableResolver(), $this->getResponseFactory());\n $exception = new RuntimeException();\n\n /** @var ResponseInterface $res */\n $res = $handler->__invoke($request, $exception, true, false, true);\n\n $this->assertTrue($res->hasHeader('Content-Type'));\n $this->assertSame('text/html', $res->getHeaderLine('Content-Type'));\n }"} {"repo":"slim","file":"tests/Handlers/ErrorHandlerTest.php","line":479,"symbol":"testLogErrorRenderer","kind":"method","lang":"php","code":"public function testLogErrorRenderer()\n {\n $renderer = function () {\n return '';\n };\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $callableResolverProphecy\n ->resolve('logErrorRenderer')\n ->willReturn($renderer)\n ->shouldBeCalledOnce();\n\n $loggerProphecy = $this->prophesize(LoggerInterface::class);\n $loggerProphecy\n ->error(Argument::type('string'))\n ->shouldBeCalled();\n\n $handler = new ErrorHandler(\n $callableResolverProphecy->reveal(),\n $this->getResponseFactory(),\n $loggerProphecy->reveal()\n );\n $handler->setLogErrorRenderer('logErrorRenderer');\n\n $displayErrorDetailsProperty = new ReflectionProperty($handler, 'displayErrorDetails');\n $this->setAccessible($displayErrorDetailsProperty);\n $displayErrorDetailsProperty->setValue($handler, true);\n\n $exception = new RuntimeException();\n $exceptionProperty = new ReflectionProperty($handler, 'exception');\n $this->setAccessible($exceptionProperty);\n $exceptionProperty->setValue($handler, $"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":18,"symbol":"RequestResponseNamedArgsTest","kind":"class","lang":"php","code":"class RequestResponseNamedArgsTest extends TestCase\n{\n private ServerRequestInterface $request;\n private ResponseInterface $response;\n\n private const PHP_8_0_VERSION_ID = 80000;\n\n public function setUp(): void\n {\n $this->request = $this->createMock(ServerRequestInterface::class);\n $this->response = $this->createMock(ResponseInterface::class);\n }\n\n public function testCallingWithEmptyArguments()\n {\n if (PHP_VERSION_ID < self::PHP_8_0_VERSION_ID) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $args = [];\n $invocationStrategy = new RequestResponseNamedArgs();\n\n $callback = function ($request, $response) {\n $this->assertSame($this->request, $request);\n $this->assertSame($this->response, $response);\n\n return $response;\n };\n\n $this->assertSame($this->response, $invocationStrategy($callback, $this->request, $this->response, $args));\n }\n\n public function testCallingWithKnownArguments()\n {\n if (PHP_VERSION_ID < self::PHP_8_0_VERSION_ID) {\n $this->markTestSkipped('Named arguments are no"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":25,"symbol":"setUp","kind":"method","lang":"php","code":"public function setUp(): void\n {\n $this->request = $this->createMock(ServerRequestInterface::class);\n $this->response = $this->createMock(ResponseInterface::class);\n }"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":31,"symbol":"testCallingWithEmptyArguments","kind":"method","lang":"php","code":"public function testCallingWithEmptyArguments()\n {\n if (PHP_VERSION_ID < self::PHP_8_0_VERSION_ID) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $args = [];\n $invocationStrategy = new RequestResponseNamedArgs();\n\n $callback = function ($request, $response) {\n $this->assertSame($this->request, $request);\n $this->assertSame($this->response, $response);\n\n return $response;\n };\n\n $this->assertSame($this->response, $invocationStrategy($callback, $this->request, $this->response, $args));\n }"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":50,"symbol":"testCallingWithKnownArguments","kind":"method","lang":"php","code":"public function testCallingWithKnownArguments()\n {\n if (PHP_VERSION_ID < self::PHP_8_0_VERSION_ID) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $args = [\n 'name' => 'world',\n 'greeting' => 'hello',\n ];\n\n $invocationStrategy = new RequestResponseNamedArgs();\n\n $callback = function ($request, $response, $greeting, $name) use ($args) {\n $this->assertSame($this->request, $request);\n $this->assertSame($this->response, $response);\n $this->assertSame($greeting, $args['greeting']);\n $this->assertSame($name, $args['name']);\n\n return $response;\n };\n\n $this->assertSame($this->response, $invocationStrategy($callback, $this->request, $this->response, $args));\n }"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":75,"symbol":"testCallingWithOptionalArguments","kind":"method","lang":"php","code":"public function testCallingWithOptionalArguments()\n {\n if (PHP_VERSION_ID < 80000) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $args = [\n 'name' => 'world',\n ];\n\n $invocationStrategy = new RequestResponseNamedArgs();\n\n $callback = function ($request, $response, $greeting = 'Hello', $name = 'Rob') use ($args) {\n $this->assertSame($this->request, $request);\n $this->assertSame($this->response, $response);\n $this->assertSame($greeting, 'Hello');\n $this->assertSame($name, $args['name']);\n\n return $response;\n };\n\n $this->assertSame($this->response, $invocationStrategy($callback, $this->request, $this->response, $args));\n }"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":99,"symbol":"testCallingWithUnknownAndVariadic","kind":"method","lang":"php","code":"public function testCallingWithUnknownAndVariadic()\n {\n if (PHP_VERSION_ID < self::PHP_8_0_VERSION_ID) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $args = [\n 'name' => 'world',\n 'greeting' => 'hello',\n ];\n\n $invocationStrategy = new RequestResponseNamedArgs();\n\n $callback = function ($request, $response, ...$arguments) use ($args) {\n $this->assertSame($this->request, $request);\n $this->assertSame($this->response, $response);\n $this->assertSame($args, $arguments);\n\n return $response;\n };\n\n $this->assertSame($this->response, $invocationStrategy($callback, $this->request, $this->response, $args));\n }"} {"repo":"slim","file":"tests/Handlers/Strategies/RequestResponseNamedArgsTest.php","line":123,"symbol":"testCallingWithMixedKnownAndUnknownParametersAndVariadic","kind":"method","lang":"php","code":"public function testCallingWithMixedKnownAndUnknownParametersAndVariadic()\n {\n if (PHP_VERSION_ID < self::PHP_8_0_VERSION_ID) {\n $this->markTestSkipped('Named arguments are not supported in PHP versions prior to 8.0');\n }\n\n $known = [\n 'name' => 'world',\n 'greeting' => 'hello',\n ];\n $unknown = [\n 'foo' => 'foo',\n 'bar' => 'bar',\n ];\n $args = array_merge($known, $unknown);\n $invocationStrategy = new RequestResponseNamedArgs();\n\n $callback = function ($request, $response, $name, $greeting, ...$arguments) use ($known, $unknown) {\n $this->assertSame($this->request, $request);\n $this->assertSame($this->response, $response);\n $this->assertSame($name, $known['name']);\n $this->assertSame($greeting, $known['greeting']);\n $this->assertSame($unknown, $arguments);\n\n return $response;\n };\n\n $this->assertSame($this->response, $invocationStrategy($callback, $this->request, $this->response, $args));\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":23,"symbol":"BodyParsingMiddlewareTest","kind":"class","lang":"php","code":"class BodyParsingMiddlewareTest extends TestCase\n{\n /**\n * Create a request handler that simply assigns the $request that it receives to a public property\n * of the returned response, so that we can then inspect that request.\n */\n protected function createRequestHandler(): RequestHandlerInterface\n {\n $response = $this->createResponse();\n return new class ($response) implements RequestHandlerInterface {\n private $response;\n public $request;\n\n public function __construct(ResponseInterface $response)\n {\n $this->response = $response;\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $this->request = $request;\n return $this->response;\n }\n };\n }\n\n /**\n * @param string $contentType\n * @param string $body\n * @return ServerRequestInterface\n */\n protected function createRequestWithBody($contentType, $body)\n {\n $request = $this->createServerRequest('/', 'POST');\n if (is_string($contentType)) {\n $request = $request->withHeader('Content-"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":29,"symbol":"createRequestHandler","kind":"method","lang":"php","doc":"Create a request handler that simply assigns the $request that it receives to a public property of the returned response, so that we can then inspect that request.","code":"protected function createRequestHandler(): RequestHandlerInterface\n {\n $response = $this->createResponse();\n return new class ($response) implements RequestHandlerInterface {\n private $response;\n public $request;\n\n public function __construct(ResponseInterface $response)\n {\n $this->response = $response;\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $this->request = $request;\n return $this->response;\n }\n };\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":36,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct(ResponseInterface $response)\n {\n $this->response = $response;\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":41,"symbol":"handle","kind":"method","lang":"php","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $this->request = $request;\n return $this->response;\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":54,"symbol":"createRequestWithBody","kind":"method","lang":"php","doc":"@param string $contentType @param string $body @return ServerRequestInterface","code":"protected function createRequestWithBody($contentType, $body)\n {\n $request = $this->createServerRequest('/', 'POST');\n if (is_string($contentType)) {\n $request = $request->withHeader('Content-Type', $contentType);\n }\n if (is_string($body)) {\n $request = $request->withBody($this->createStream($body));\n }\n return $request;\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":67,"symbol":"parsingProvider","kind":"method","lang":"php","code":"public static function parsingProvider()\n {\n return [\n 'form' => [\n 'application/x-www-form-urlencoded;charset=utf8',\n 'foo=bar',\n ['foo' => 'bar'],\n ],\n 'json' => [\n \"application/json\",\n '{\"foo\":\"bar\"}',\n ['foo' => 'bar'],\n ],\n 'json-with-charset' => [\n \"application/json\\t ; charset=utf8\",\n '{\"foo\":\"bar\"}',\n ['foo' => 'bar'],\n ],\n 'json-suffix' => [\n 'application/vnd.api+json;charset=utf8',\n '{\"foo\":\"bar\"}',\n ['foo' => 'bar'],\n ],\n 'xml' => [\n 'application/xml',\n 'John',\n simplexml_load_string('John'),\n ],\n 'xml-suffix' => [\n 'application/hal+xml;charset=utf8',\n 'John',\n simplexml_load_string('John'),\n ],\n 'text-xml' => [\n 'text/xml'"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":151,"symbol":"testParsing","kind":"method","lang":"php","doc":"@dataProvider parsingProvider","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('parsingProvider')]\n public function testParsing($contentType, $body, $expected)\n {\n $request = $this->createRequestWithBody($contentType, $body);\n\n $middleware = new BodyParsingMiddleware();\n $requestHandler = $this->createRequestHandler();\n $middleware->process($request, $requestHandler);\n\n $this->assertEquals($expected, $requestHandler->request->getParsedBody());\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":163,"symbol":"testParsingWithARegisteredParser","kind":"method","lang":"php","code":"public function testParsingWithARegisteredParser()\n {\n $request = $this->createRequestWithBody('application/vnd.api+json', '{\"foo\":\"bar\"}');\n\n $parsers = [\n 'application/vnd.api+json' => function ($input) {\n return ['data' => $input];\n },\n ];\n $middleware = new BodyParsingMiddleware($parsers);\n $requestHandler = $this->createRequestHandler();\n $middleware->process($request, $requestHandler);\n\n $this->assertSame(['data' => '{\"foo\":\"bar\"}'], $requestHandler->request->getParsedBody());\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":179,"symbol":"testParsingFailsWhenAnInvalidTypeIsReturned","kind":"method","lang":"php","code":"public function testParsingFailsWhenAnInvalidTypeIsReturned()\n {\n $request = $this->createRequestWithBody('application/json;charset=utf8', '{\"foo\":\"bar\"}');\n\n $parsers = [\n 'application/json' => function ($input) {\n return 10; // invalid - should return null, array or object\n },\n ];\n $middleware = new BodyParsingMiddleware($parsers);\n\n $this->expectException(RuntimeException::class);\n $middleware->process($request, $this->createRequestHandler());\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":194,"symbol":"testSettingAndGettingAParser","kind":"method","lang":"php","code":"public function testSettingAndGettingAParser()\n {\n $middleware = new BodyParsingMiddleware();\n $parser = function ($input) {\n return ['data' => $input];\n };\n\n $this->assertFalse($middleware->hasBodyParser('text/foo'));\n\n $middleware->registerBodyParser('text/foo', $parser);\n $this->assertTrue($middleware->hasBodyParser('text/foo'));\n\n $this->assertSame($parser, $middleware->getBodyParser('text/foo'));\n }"} {"repo":"slim","file":"tests/Middleware/BodyParsingMiddlewareTest.php","line":209,"symbol":"testGettingUnknownParser","kind":"method","lang":"php","code":"public function testGettingUnknownParser()\n {\n $middleware = new BodyParsingMiddleware();\n\n $this->expectException(RuntimeException::class);\n $middleware->getBodyParser('text/foo');\n }"} {"repo":"slim","file":"tests/Middleware/ContentLengthMiddlewareTest.php","line":17,"symbol":"ContentLengthMiddlewareTest","kind":"class","lang":"php","code":"class ContentLengthMiddlewareTest extends TestCase\n{\n public function testAddsContentLength()\n {\n $request = $this->createServerRequest('/');\n $responseFactory = $this->getResponseFactory();\n\n $mw = function ($request, $handler) use ($responseFactory) {\n $response = $responseFactory->createResponse();\n $response->getBody()->write('Body');\n return $response;\n };\n $mw2 = new ContentLengthMiddleware();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandlerInterface::class),\n null\n );\n $middlewareDispatcher->addCallable($mw);\n $middlewareDispatcher->addMiddleware($mw2);\n $response = $middlewareDispatcher->handle($request);\n\n $this->assertSame('4', $response->getHeaderLine('Content-Length'));\n }\n}"} {"repo":"slim","file":"tests/Middleware/ContentLengthMiddlewareTest.php","line":19,"symbol":"testAddsContentLength","kind":"method","lang":"php","code":"public function testAddsContentLength()\n {\n $request = $this->createServerRequest('/');\n $responseFactory = $this->getResponseFactory();\n\n $mw = function ($request, $handler) use ($responseFactory) {\n $response = $responseFactory->createResponse();\n $response->getBody()->write('Body');\n return $response;\n };\n $mw2 = new ContentLengthMiddleware();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandlerInterface::class),\n null\n );\n $middlewareDispatcher->addCallable($mw);\n $middlewareDispatcher->addMiddleware($mw2);\n $response = $middlewareDispatcher->handle($request);\n\n $this->assertSame('4', $response->getHeaderLine('Content-Length'));\n }"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":28,"symbol":"ErrorMiddlewareTest","kind":"class","lang":"php","code":"class ErrorMiddlewareTest extends TestCase\n{\n private function getMockLogger(): LoggerInterface\n {\n return $this->createMock(LoggerInterface::class);\n }\n\n public function testSetErrorHandler()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $routingMiddleware = new RoutingMiddleware(\n $app->getRouteResolver(),\n $app->getRouteCollector()->getRouteParser()\n );\n $app->add($routingMiddleware);\n\n $exception = HttpNotFoundException::class;\n $handler = (function () {\n $response = $this->createResponse(500);\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this);\n\n $errorMiddleware = new ErrorMiddleware(\n $callableResolver,\n $this->getResponseFactory(),\n false,\n false,\n false,\n $logger\n );\n $errorMiddleware->setErrorHandler($exception, $handler);\n $app->add($errorMiddleware);\n\n $request = $this->crea"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":30,"symbol":"getMockLogger","kind":"method","lang":"php","code":"private function getMockLogger(): LoggerInterface\n {\n return $this->createMock(LoggerInterface::class);\n }"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":35,"symbol":"testSetErrorHandler","kind":"method","lang":"php","code":"public function testSetErrorHandler()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $routingMiddleware = new RoutingMiddleware(\n $app->getRouteResolver(),\n $app->getRouteCollector()->getRouteParser()\n );\n $app->add($routingMiddleware);\n\n $exception = HttpNotFoundException::class;\n $handler = (function () {\n $response = $this->createResponse(500);\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this);\n\n $errorMiddleware = new ErrorMiddleware(\n $callableResolver,\n $this->getResponseFactory(),\n false,\n false,\n false,\n $logger\n );\n $errorMiddleware->setErrorHandler($exception, $handler);\n $app->add($errorMiddleware);\n\n $request = $this->createServerRequest('/foo/baz/');\n $app->run($request);\n\n $this->expectOutputString('Oops..');\n }"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":72,"symbol":"testSetDefaultErrorHandler","kind":"method","lang":"php","code":"public function testSetDefaultErrorHandler()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $routingMiddleware = new RoutingMiddleware(\n $app->getRouteResolver(),\n $app->getRouteCollector()->getRouteParser()\n );\n $app->add($routingMiddleware);\n\n $handler = (function () {\n $response = $this->createResponse();\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this);\n\n $errorMiddleware = new ErrorMiddleware(\n $callableResolver,\n $this->getResponseFactory(),\n false,\n false,\n false,\n $logger\n );\n $errorMiddleware->setDefaultErrorHandler($handler);\n $app->add($errorMiddleware);\n\n $request = $this->createServerRequest('/foo/baz/');\n $app->run($request);\n\n $this->expectOutputString('Oops..');\n }"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":108,"symbol":"testSetDefaultErrorHandlerThrowsException","kind":"method","lang":"php","code":"public function testSetDefaultErrorHandlerThrowsException()\n {\n $this->expectException(RuntimeException::class);\n\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $errorMiddleware = new ErrorMiddleware(\n $callableResolver,\n $this->getResponseFactory(),\n false,\n false,\n false,\n $logger\n );\n $errorMiddleware->setDefaultErrorHandler('Uncallable');\n $errorMiddleware->getDefaultErrorHandler();\n }"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":129,"symbol":"testGetErrorHandlerWillReturnDefaultErrorHandlerForUnhandledExceptions","kind":"method","lang":"php","code":"public function testGetErrorHandlerWillReturnDefaultErrorHandlerForUnhandledExceptions()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $middleware = new ErrorMiddleware($callableResolver, $this->getResponseFactory(), false, false, false, $logger);\n $exception = MockCustomException::class;\n $handler = $middleware->getErrorHandler($exception);\n $this->assertInstanceOf(ErrorHandler::class, $handler);\n }"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":142,"symbol":"testSuperclassExceptionHandlerHandlesExceptionWithSubclassExactMatch","kind":"method","lang":"php","code":"public function testSuperclassExceptionHandlerHandlesExceptionWithSubclassExactMatch()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n $middleware = new ErrorMiddleware($callableResolver, $this->getResponseFactory(), false, false, false, $logger);\n $app->add(function ($request, $handler) {\n throw new LogicException('This is a LogicException...');\n });\n $middleware->setErrorHandler(LogicException::class, (function (ServerRequestInterface $request, $exception) {\n $response = $this->createResponse();\n $response->getBody()->write($exception->getMessage());\n return $response;\n })->bindTo($this), true); // - true; handle subclass but also LogicException explicitly\n $middleware->setDefaultErrorHandler((function () {\n $response = $this->createResponse();\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this));\n $app->add($middleware);\n $app->get('/foo', function (ServerRequest"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":172,"symbol":"testSuperclassExceptionHandlerHandlesSubclassException","kind":"method","lang":"php","code":"public function testSuperclassExceptionHandlerHandlesSubclassException()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $middleware = new ErrorMiddleware($callableResolver, $this->getResponseFactory(), false, false, false, $logger);\n\n $app->add(function ($request, $handler) {\n throw new InvalidArgumentException('This is a subclass of LogicException...');\n });\n\n $middleware->setErrorHandler(LogicException::class, (function (ServerRequestInterface $request, $exception) {\n $response = $this->createResponse();\n $response->getBody()->write($exception->getMessage());\n return $response;\n })->bindTo($this), true); // - true; handle subclass\n\n $middleware->setDefaultErrorHandler((function () {\n $response = $this->createResponse();\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this));\n\n $app->add($middleware);\n\n $app->get('/foo', function (ServerRequestInterface $request, R"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":210,"symbol":"testSuperclassExceptionHandlerDoesNotHandleSubclassException","kind":"method","lang":"php","code":"public function testSuperclassExceptionHandlerDoesNotHandleSubclassException()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $middleware = new ErrorMiddleware($callableResolver, $this->getResponseFactory(), false, false, false, $logger);\n\n $app->add(function ($request, $handler) {\n throw new InvalidArgumentException('This is a subclass of LogicException...');\n });\n\n $middleware->setErrorHandler(LogicException::class, (function (ServerRequestInterface $request, $exception) {\n $response = $this->createResponse();\n $response->getBody()->write($exception->getMessage());\n return $response;\n })->bindTo($this), false); // - false; don't handle subclass\n\n $middleware->setDefaultErrorHandler((function () {\n $response = $this->createResponse();\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this));\n\n $app->add($middleware);\n\n $app->get('/foo', function (ServerRequestInterfa"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":248,"symbol":"testHandleMultipleExceptionsAddedAsArray","kind":"method","lang":"php","code":"public function testHandleMultipleExceptionsAddedAsArray()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $middleware = new ErrorMiddleware($callableResolver, $this->getResponseFactory(), false, false, false, $logger);\n\n $app->add(function ($request, $handler) {\n throw new InvalidArgumentException('This is an invalid argument exception...');\n });\n\n $handler = (function (ServerRequestInterface $request, $exception) {\n $response = $this->createResponse();\n $response->getBody()->write($exception->getMessage());\n return $response;\n });\n\n $middleware->setErrorHandler([LogicException::class, InvalidArgumentException::class], $handler->bindTo($this));\n\n $middleware->setDefaultErrorHandler((function () {\n $response = $this->createResponse();\n $response->getBody()->write('Oops..');\n return $response;\n })->bindTo($this));\n\n $app->add($middleware);\n\n $app->get('/foo', function (ServerRequestIn"} {"repo":"slim","file":"tests/Middleware/ErrorMiddlewareTest.php","line":288,"symbol":"testErrorHandlerHandlesThrowables","kind":"method","lang":"php","code":"public function testErrorHandlerHandlesThrowables()\n {\n $responseFactory = $this->getResponseFactory();\n $app = new App($responseFactory);\n $callableResolver = $app->getCallableResolver();\n $logger = $this->getMockLogger();\n\n $middleware = new ErrorMiddleware($callableResolver, $this->getResponseFactory(), false, false, false, $logger);\n\n $app->add(function ($request, $handler) {\n throw new Error('Oops..');\n });\n\n $middleware->setDefaultErrorHandler((function (ServerRequestInterface $request, $exception) {\n $response = $this->createResponse();\n $response->getBody()->write($exception->getMessage());\n return $response;\n })->bindTo($this));\n\n $app->add($middleware);\n\n $app->get('/foo', function (ServerRequestInterface $request, ResponseInterface $response) {\n $response->getBody()->write('...');\n return $response;\n });\n\n $request = $this->createServerRequest('/foo');\n $app->run($request);\n\n $this->expectOutputString('Oops..');\n }"} {"repo":"slim","file":"tests/Middleware/MethodOverrideMiddlewareTest.php","line":19,"symbol":"MethodOverrideMiddlewareTest","kind":"class","lang":"php","code":"class MethodOverrideMiddlewareTest extends TestCase\n{\n public function testHeader()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('PUT', $request->getMethod());\n return $responseFactory->createResponse();\n })->bindTo($this);\n $methodOverrideMiddleware = new MethodOverrideMiddleware();\n\n $request = $this\n ->createServerRequest('/', 'POST')\n ->withHeader('X-Http-Method-Override', 'PUT');\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandler::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($methodOverrideMiddleware);\n $middlewareDispatcher->handle($request);\n }\n\n public function testBodyParam()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('PUT', $request->getMethod());\n "} {"repo":"slim","file":"tests/Middleware/MethodOverrideMiddlewareTest.php","line":21,"symbol":"testHeader","kind":"method","lang":"php","code":"public function testHeader()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('PUT', $request->getMethod());\n return $responseFactory->createResponse();\n })->bindTo($this);\n $methodOverrideMiddleware = new MethodOverrideMiddleware();\n\n $request = $this\n ->createServerRequest('/', 'POST')\n ->withHeader('X-Http-Method-Override', 'PUT');\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandler::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($methodOverrideMiddleware);\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/Middleware/MethodOverrideMiddlewareTest.php","line":43,"symbol":"testBodyParam","kind":"method","lang":"php","code":"public function testBodyParam()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('PUT', $request->getMethod());\n return $responseFactory->createResponse();\n })->bindTo($this);\n\n $methodOverrideMiddleware = new MethodOverrideMiddleware();\n\n $request = $this\n ->createServerRequest('/', 'POST')\n ->withParsedBody(['_METHOD' => 'PUT']);\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandler::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($methodOverrideMiddleware);\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/Middleware/MethodOverrideMiddlewareTest.php","line":66,"symbol":"testHeaderPreferred","kind":"method","lang":"php","code":"public function testHeaderPreferred()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('DELETE', $request->getMethod());\n return $responseFactory->createResponse();\n })->bindTo($this);\n\n $methodOverrideMiddleware = new MethodOverrideMiddleware();\n\n $request = $this\n ->createServerRequest('/', 'POST')\n ->withHeader('X-Http-Method-Override', 'DELETE')\n ->withParsedBody((object) ['_METHOD' => 'PUT']);\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandler::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($methodOverrideMiddleware);\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/Middleware/MethodOverrideMiddlewareTest.php","line":90,"symbol":"testNoOverride","kind":"method","lang":"php","code":"public function testNoOverride()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('POST', $request->getMethod());\n return $responseFactory->createResponse();\n })->bindTo($this);\n\n $methodOverrideMiddleware = new MethodOverrideMiddleware();\n\n $request = $this->createServerRequest('/', 'POST');\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandler::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($methodOverrideMiddleware);\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/Middleware/MethodOverrideMiddlewareTest.php","line":111,"symbol":"testNoOverrideRewindEofBodyStream","kind":"method","lang":"php","code":"public function testNoOverrideRewindEofBodyStream()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (Request $request, RequestHandler $handler) use ($responseFactory) {\n $this->assertSame('POST', $request->getMethod());\n return $responseFactory->createResponse();\n })->bindTo($this);\n\n $methodOverrideMiddleware = new MethodOverrideMiddleware();\n\n $request = $this->createServerRequest('/', 'POST');\n\n // Prophesize the body stream for which `eof()` returns `true` and the\n // `rewind()` has to be called.\n $bodyProphecy = $this->prophesize(StreamInterface::class);\n /** @noinspection PhpUndefinedMethodInspection */\n $bodyProphecy->eof()\n ->willReturn(true)\n ->shouldBeCalled();\n /** @noinspection PhpUndefinedMethodInspection */\n $bodyProphecy->rewind()\n ->shouldBeCalled();\n /** @var StreamInterface $body */\n $body = $bodyProphecy->reveal();\n $request = $request->withBody($body);\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandler::class),\n "} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":22,"symbol":"OutputBufferingMiddlewareTest","kind":"class","lang":"php","code":"class OutputBufferingMiddlewareTest extends TestCase\n{\n public function testStyleDefaultValid()\n {\n $middleware = new OutputBufferingMiddleware($this->getStreamFactory());\n\n $reflectionProperty = new ReflectionProperty($middleware, 'style');\n $this->setAccessible($reflectionProperty);\n $value = $reflectionProperty->getValue($middleware);\n\n $this->assertSame('append', $value);\n }\n\n public function testStyleCustomValid()\n {\n $middleware = new OutputBufferingMiddleware($this->getStreamFactory(), 'prepend');\n\n $reflectionProperty = new ReflectionProperty($middleware, 'style');\n $this->setAccessible($reflectionProperty);\n $value = $reflectionProperty->getValue($middleware);\n\n $this->assertSame('prepend', $value);\n }\n\n public function testStyleCustomInvalid()\n {\n $this->expectException(InvalidArgumentException::class);\n\n new OutputBufferingMiddleware($this->getStreamFactory(), 'foo');\n }\n\n public function testAppend()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = function ($request, $handler) use ($responseFactory) {\n $response"} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":24,"symbol":"testStyleDefaultValid","kind":"method","lang":"php","code":"public function testStyleDefaultValid()\n {\n $middleware = new OutputBufferingMiddleware($this->getStreamFactory());\n\n $reflectionProperty = new ReflectionProperty($middleware, 'style');\n $this->setAccessible($reflectionProperty);\n $value = $reflectionProperty->getValue($middleware);\n\n $this->assertSame('append', $value);\n }"} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":35,"symbol":"testStyleCustomValid","kind":"method","lang":"php","code":"public function testStyleCustomValid()\n {\n $middleware = new OutputBufferingMiddleware($this->getStreamFactory(), 'prepend');\n\n $reflectionProperty = new ReflectionProperty($middleware, 'style');\n $this->setAccessible($reflectionProperty);\n $value = $reflectionProperty->getValue($middleware);\n\n $this->assertSame('prepend', $value);\n }"} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":46,"symbol":"testStyleCustomInvalid","kind":"method","lang":"php","code":"public function testStyleCustomInvalid()\n {\n $this->expectException(InvalidArgumentException::class);\n\n new OutputBufferingMiddleware($this->getStreamFactory(), 'foo');\n }"} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":53,"symbol":"testAppend","kind":"method","lang":"php","code":"public function testAppend()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = function ($request, $handler) use ($responseFactory) {\n $response = $responseFactory->createResponse();\n $response->getBody()->write('Body');\n echo 'Test';\n\n return $response;\n };\n $outputBufferingMiddleware = new OutputBufferingMiddleware($this->getStreamFactory(), 'append');\n\n $request = $this->createServerRequest('/', 'GET');\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandlerInterface::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($outputBufferingMiddleware);\n $response = $middlewareDispatcher->handle($request);\n\n $this->assertSame('BodyTest', (string) $response->getBody());\n }"} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":78,"symbol":"testPrepend","kind":"method","lang":"php","code":"public function testPrepend()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = function ($request, $handler) use ($responseFactory) {\n $response = $responseFactory->createResponse();\n $response->getBody()->write('Body');\n echo 'Test';\n\n return $response;\n };\n $outputBufferingMiddleware = new OutputBufferingMiddleware($this->getStreamFactory(), 'prepend');\n\n $request = $this->createServerRequest('/', 'GET');\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandlerInterface::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($outputBufferingMiddleware);\n $response = $middlewareDispatcher->handle($request);\n\n $this->assertSame('TestBody', (string) $response->getBody());\n }"} {"repo":"slim","file":"tests/Middleware/OutputBufferingMiddlewareTest.php","line":103,"symbol":"testOutputBufferIsCleanedWhenThrowableIsCaught","kind":"method","lang":"php","code":"public function testOutputBufferIsCleanedWhenThrowableIsCaught()\n {\n $this->getResponseFactory();\n $middleware = (function ($request, $handler) {\n echo \"Test\";\n $this->assertSame('Test', ob_get_contents());\n throw new Exception('Oops...');\n })->bindTo($this);\n $outputBufferingMiddleware = new OutputBufferingMiddleware($this->getStreamFactory(), 'prepend');\n\n $request = $this->createServerRequest('/', 'GET');\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $this->createMock(RequestHandlerInterface::class),\n null\n );\n $middlewareDispatcher->addCallable($middleware);\n $middlewareDispatcher->addMiddleware($outputBufferingMiddleware);\n\n try {\n $middlewareDispatcher->handle($request);\n } catch (Exception $e) {\n $this->assertSame('', ob_get_contents());\n }\n }"} {"repo":"slim","file":"tests/Middleware/RoutingMiddlewareTest.php","line":31,"symbol":"RoutingMiddlewareTest","kind":"class","lang":"php","code":"class RoutingMiddlewareTest extends TestCase\n{\n protected function getRouteCollector()\n {\n $callableResolver = new CallableResolver();\n $responseFactory = $this->getResponseFactory();\n $routeCollector = new RouteCollector($responseFactory, $callableResolver);\n $routeCollector->map(['GET'], '/hello/{name}', null);\n return $routeCollector;\n }\n\n public function testRouteIsStoredOnSuccessfulMatch()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (ServerRequestInterface $request) use ($responseFactory) {\n // route is available\n $route = $request->getAttribute(RouteContext::ROUTE);\n $this->assertNotNull($route);\n $this->assertSame('foo', $route->getArgument('name'));\n\n // routeParser is available\n $routeParser = $request->getAttribute(RouteContext::ROUTE_PARSER);\n $this->assertNotNull($routeParser);\n $this->assertInstanceOf(RouteParserInterface::class, $routeParser);\n\n // routingResults is available\n $routingResults = $request->getAttribute(RouteContext::ROUTING_RESULTS);\n $thi"} {"repo":"slim","file":"tests/Middleware/RoutingMiddlewareTest.php","line":33,"symbol":"getRouteCollector","kind":"method","lang":"php","code":"protected function getRouteCollector()\n {\n $callableResolver = new CallableResolver();\n $responseFactory = $this->getResponseFactory();\n $routeCollector = new RouteCollector($responseFactory, $callableResolver);\n $routeCollector->map(['GET'], '/hello/{name}', null);\n return $routeCollector;\n }"} {"repo":"slim","file":"tests/Middleware/RoutingMiddlewareTest.php","line":42,"symbol":"testRouteIsStoredOnSuccessfulMatch","kind":"method","lang":"php","code":"public function testRouteIsStoredOnSuccessfulMatch()\n {\n $responseFactory = $this->getResponseFactory();\n $middleware = (function (ServerRequestInterface $request) use ($responseFactory) {\n // route is available\n $route = $request->getAttribute(RouteContext::ROUTE);\n $this->assertNotNull($route);\n $this->assertSame('foo', $route->getArgument('name'));\n\n // routeParser is available\n $routeParser = $request->getAttribute(RouteContext::ROUTE_PARSER);\n $this->assertNotNull($routeParser);\n $this->assertInstanceOf(RouteParserInterface::class, $routeParser);\n\n // routingResults is available\n $routingResults = $request->getAttribute(RouteContext::ROUTING_RESULTS);\n $this->assertInstanceOf(RoutingResults::class, $routingResults);\n return $responseFactory->createResponse();\n })->bindTo($this);\n\n $routeCollector = $this->getRouteCollector();\n $routeParser = new RouteParser($routeCollector);\n $routeResolver = new RouteResolver($routeCollector);\n $routingMiddleware = new RoutingMiddleware($routeResolver, $routePar"} {"repo":"slim","file":"tests/Middleware/RoutingMiddlewareTest.php","line":78,"symbol":"testRouteIsNotStoredOnMethodNotAllowed","kind":"method","lang":"php","code":"public function testRouteIsNotStoredOnMethodNotAllowed()\n {\n $routeCollector = $this->getRouteCollector();\n $routeParser = new RouteParser($routeCollector);\n $routeResolver = new RouteResolver($routeCollector);\n $routingMiddleware = new RoutingMiddleware($routeResolver, $routeParser);\n\n $request = $this->createServerRequest('https://example.com:443/hello/foo', 'POST');\n $requestHandlerProphecy = $this->prophesize(RequestHandlerInterface::class);\n /** @var RequestHandlerInterface $requestHandler */\n $requestHandler = $requestHandlerProphecy->reveal();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($requestHandler, null);\n $middlewareDispatcher->addMiddleware($routingMiddleware);\n\n try {\n $middlewareDispatcher->handle($request);\n $this->fail('HTTP method should not have been allowed');\n } catch (HttpMethodNotAllowedException $exception) {\n $request = $exception->getRequest();\n\n // route is not available\n $route = $request->getAttribute(RouteContext::ROUTE);\n $this->assertNull($route);\n\n // routeParser is avail"} {"repo":"slim","file":"tests/Middleware/RoutingMiddlewareTest.php","line":115,"symbol":"testRouteIsNotStoredOnNotFound","kind":"method","lang":"php","code":"public function testRouteIsNotStoredOnNotFound()\n {\n $routeCollector = $this->getRouteCollector();\n $routeParser = new RouteParser($routeCollector);\n $routeResolver = new RouteResolver($routeCollector);\n $routingMiddleware = new RoutingMiddleware($routeResolver, $routeParser);\n\n $request = $this->createServerRequest('https://example.com:443/goodbye', 'GET');\n $requestHandlerProphecy = $this->prophesize(RequestHandlerInterface::class);\n /** @var RequestHandlerInterface $requestHandler */\n $requestHandler = $requestHandlerProphecy->reveal();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($requestHandler, null);\n $middlewareDispatcher->addMiddleware($routingMiddleware);\n\n try {\n $middlewareDispatcher->handle($request);\n $this->fail('HTTP route should not have been found');\n } catch (HttpNotFoundException $exception) {\n $request = $exception->getRequest();\n\n // route is not available\n $route = $request->getAttribute(RouteContext::ROUTE);\n $this->assertNull($route);\n\n // routeParser is available\n $rout"} {"repo":"slim","file":"tests/Middleware/RoutingMiddlewareTest.php","line":152,"symbol":"testPerformRoutingThrowsExceptionOnInvalidRoutingResultsRouteStatus","kind":"method","lang":"php","code":"public function testPerformRoutingThrowsExceptionOnInvalidRoutingResultsRouteStatus()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('An unexpected error occurred while performing routing.');\n\n // Prophesize the `RoutingResults` instance that would return an invalid route\n // status when the method `getRouteStatus()` gets called.\n $routingResultsProphecy = $this->prophesize(RoutingResults::class);\n /** @noinspection PhpUndefinedMethodInspection */\n $routingResultsProphecy->getRouteStatus()\n ->willReturn(-1)\n ->shouldBeCalledOnce();\n /** @var RoutingResults $routingResults */\n $routingResults = $routingResultsProphecy->reveal();\n\n // Prophesize the `RouteParserInterface` instance will be created.\n $routeParserProphecy = $this->prophesize(RouteParser::class);\n /** @var RouteParserInterface $routeParser */\n $routeParser = $routeParserProphecy->reveal();\n\n // Prophesize the `RouteResolverInterface` that would return the `RoutingResults`\n // defined above, when the method `computeRoutingResults()` gets called.\n $rou"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":28,"symbol":"MiddlewareDispatcherTest","kind":"class","lang":"php","code":"class MiddlewareDispatcherTest extends TestCase\n{\n public static function setUpBeforeClass(): void\n {\n function testProcessRequest(ServerRequestInterface $request, RequestHandlerInterface $handler)\n {\n return $handler->handle($request);\n }\n }\n\n public function testAddMiddleware(): void\n {\n $responseFactory = $this->getResponseFactory();\n $callable = function ($request, $handler) use ($responseFactory) {\n return $responseFactory->createResponse();\n };\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestHandlerProphecy = $this->prophesize(RequestHandlerInterface::class);\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($requestHandlerProphecy->reveal());\n $middlewareDispatcher->add($callable);\n\n $response = $middlewareDispatcher->handle($requestProphecy->reveal());\n $this->assertInstanceOf(ResponseInterface::class, $response);\n }\n\n public function testNamedFunctionIsResolved(): void\n {\n $handler = new MockRequestHandler();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null);\n "} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":30,"symbol":"setUpBeforeClass","kind":"method","lang":"php","code":"public static function setUpBeforeClass(): void\n {\n function testProcessRequest(ServerRequestInterface $request, RequestHandlerInterface $handler)\n {\n return $handler->handle($request);\n }\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":32,"symbol":"testProcessRequest","kind":"function","lang":"php","code":"function testProcessRequest(ServerRequestInterface $request, RequestHandlerInterface $handler)\n {\n return $handler->handle($request);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":38,"symbol":"testAddMiddleware","kind":"method","lang":"php","code":"public function testAddMiddleware(): void\n {\n $responseFactory = $this->getResponseFactory();\n $callable = function ($request, $handler) use ($responseFactory) {\n return $responseFactory->createResponse();\n };\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestHandlerProphecy = $this->prophesize(RequestHandlerInterface::class);\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($requestHandlerProphecy->reveal());\n $middlewareDispatcher->add($callable);\n\n $response = $middlewareDispatcher->handle($requestProphecy->reveal());\n $this->assertInstanceOf(ResponseInterface::class, $response);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":55,"symbol":"testNamedFunctionIsResolved","kind":"method","lang":"php","code":"public function testNamedFunctionIsResolved(): void\n {\n $handler = new MockRequestHandler();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null);\n $middlewareDispatcher->addDeferred(__NAMESPACE__ . '\\testProcessRequest');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n\n $this->assertSame(1, $handler->getCalledCount());\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":68,"symbol":"testDeferredResolvedCallable","kind":"method","lang":"php","code":"public function testDeferredResolvedCallable(): void\n {\n $callable = function (ServerRequestInterface $request, RequestHandlerInterface $handler) {\n return $handler->handle($request);\n };\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $containerProphecy\n ->has('callable')\n ->willReturn(true)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->get('callable')\n ->willReturn($callable)\n ->shouldBeCalledOnce();\n\n $handler = new MockRequestHandler();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, $containerProphecy->reveal());\n $middlewareDispatcher->addDeferred('callable');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n\n $this->assertSame(1, $handler->getCalledCount());\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":97,"symbol":"testDeferredResolvedCallableWithoutContainerAndNonAdvancedCallableResolver","kind":"method","lang":"php","code":"public function testDeferredResolvedCallableWithoutContainerAndNonAdvancedCallableResolver(): void\n {\n $callable = function (ServerRequestInterface $request, RequestHandlerInterface $handler) {\n return $handler->handle($request);\n };\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $callableResolverProphecy\n ->resolve('callable')\n ->willReturn($callable)\n ->shouldBeCalledOnce();\n\n $handler = new MockRequestHandler();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null, $callableResolverProphecy->reveal());\n $middlewareDispatcher->addDeferred('callable');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n\n $this->assertSame(1, $handler->getCalledCount());\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":121,"symbol":"testDeferredResolvedCallableWithDirectConstructorCall","kind":"method","lang":"php","code":"public function testDeferredResolvedCallableWithDirectConstructorCall(): void\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $callableResolverProphecy\n ->resolve(MockMiddlewareWithoutConstructor::class)\n ->willThrow(new RuntimeException('Callable not available from resolver'))\n ->shouldBeCalledOnce();\n\n $handler = new MockRequestHandler();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null, $callableResolverProphecy->reveal());\n $middlewareDispatcher->addDeferred(MockMiddlewareWithoutConstructor::class);\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n\n $this->assertSame(1, $handler->getCalledCount());\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":141,"symbol":"deferredCallableProvider","kind":"method","lang":"php","code":"public static function deferredCallableProvider(): array\n {\n return [\n [MockMiddlewareSlimCallable::class . ':custom', new MockMiddlewareSlimCallable()],\n ['MiddlewareInstance', new MockMiddlewareWithoutConstructor()],\n ['NamedFunction', __NAMESPACE__ . '\\testProcessRequest'],\n ['Callable', function (ServerRequestInterface $request, RequestHandlerInterface $handler) {\n return $handler->handle($request);\n }],\n ['MiddlewareInterfaceNotImplemented', 'MiddlewareInterfaceNotImplemented']\n ];\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":160,"symbol":"testDeferredResolvedCallableWithContainerAndNonAdvancedCallableResolverUnableToResolveCallable","kind":"method","lang":"php","doc":"@dataProvider deferredCallableProvider @param string $callable @param callable|MiddlewareInterface","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('deferredCallableProvider')]\n public function testDeferredResolvedCallableWithContainerAndNonAdvancedCallableResolverUnableToResolveCallable(\n $callable,\n $result\n ): void {\n if ($callable === 'MiddlewareInterfaceNotImplemented') {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('Middleware MiddlewareInterfaceNotImplemented is not resolvable');\n }\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $callableResolverProphecy\n ->resolve($callable)\n ->willThrow(RuntimeException::class)\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $containerProphecy\n ->has(Argument::any())\n ->willReturn(true)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->get(Argument::any())\n ->willReturn($result)\n ->shouldBeCalledOnce();\n\n $handler = new MockRequestHandler();\n\n $middlewareDispatcher = $this->createMiddlewareDispatcher(\n $handler"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":204,"symbol":"testDeferredResolvedSlimCallable","kind":"method","lang":"php","code":"public function testDeferredResolvedSlimCallable(): void\n {\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null);\n $middlewareDispatcher->addDeferred(MockMiddlewareSlimCallable::class . ':custom');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n\n $this->assertSame(1, $handler->getCalledCount());\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":216,"symbol":"testDeferredResolvedClosureIsBoundToContainer","kind":"method","lang":"php","code":"public function testDeferredResolvedClosureIsBoundToContainer(): void\n {\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $self = $this;\n $callable = function (\n ServerRequestInterface $request,\n RequestHandlerInterface $handler\n ) use ($self) {\n $self->assertInstanceOf(ContainerInterface::class, $this);\n return $handler->handle($request);\n };\n\n $containerProphecy->has('callable')->willReturn(true);\n $containerProphecy->get('callable')->willReturn($callable);\n\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, $containerProphecy->reveal());\n $middlewareDispatcher->addDeferred('callable');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":240,"symbol":"testAddCallableBindsClosureToContainer","kind":"method","lang":"php","code":"public function testAddCallableBindsClosureToContainer(): void\n {\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $self = $this;\n $callable = function (\n ServerRequestInterface $request,\n RequestHandlerInterface $handler\n ) use (\n $self,\n $containerProphecy\n ) {\n $self->assertSame($containerProphecy->reveal(), $this);\n return $handler->handle($request);\n };\n\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, $containerProphecy->reveal());\n $middlewareDispatcher->addCallable($callable);\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":264,"symbol":"testResolvableReturnsInstantiatedObject","kind":"method","lang":"php","code":"public function testResolvableReturnsInstantiatedObject(): void\n {\n MockMiddlewareWithoutConstructor::$CalledCount = 0;\n\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null);\n $middlewareDispatcher->addDeferred(MockMiddlewareWithoutConstructor::class);\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n\n $this->assertSame(1, MockMiddlewareWithoutConstructor::$CalledCount);\n $this->assertSame(1, $handler->getCalledCount());\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":279,"symbol":"testResolveThrowsExceptionWhenResolvableDoesNotImplementMiddlewareInterface","kind":"method","lang":"php","code":"public function testResolveThrowsExceptionWhenResolvableDoesNotImplementMiddlewareInterface(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage('MiddlewareInterfaceNotImplemented is not resolvable');\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $containerProphecy\n ->has('MiddlewareInterfaceNotImplemented')\n ->willReturn(true)\n ->shouldBeCalledOnce();\n\n $containerProphecy\n ->get('MiddlewareInterfaceNotImplemented')\n ->willReturn(new stdClass())\n ->shouldBeCalledOnce();\n\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, $containerProphecy->reveal());\n $middlewareDispatcher->addDeferred('MiddlewareInterfaceNotImplemented');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":304,"symbol":"testResolveThrowsExceptionWithoutContainerAndUnresolvableClass","kind":"method","lang":"php","code":"public function testResolveThrowsExceptionWithoutContainerAndUnresolvableClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessageMatches('/(Middleware|Callable) Unresolvable::class does not exist/');\n\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null);\n $middlewareDispatcher->addDeferred('Unresolvable::class');\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":317,"symbol":"testResolveThrowsExceptionWithoutContainerNonAdvancedCallableResolverAndUnresolvableClass","kind":"method","lang":"php","code":"public function testResolveThrowsExceptionWithoutContainerNonAdvancedCallableResolverAndUnresolvableClass(): void\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessageMatches('/(Middleware|Callable) Unresolvable::class does not exist/');\n\n $unresolvable = 'Unresolvable::class';\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $callableResolverProphecy\n ->resolve($unresolvable)\n ->willThrow(RuntimeException::class)\n ->shouldBeCalledOnce();\n\n $handler = new MockRequestHandler();\n $middlewareDispatcher = $this->createMiddlewareDispatcher($handler, null, $callableResolverProphecy->reveal());\n $middlewareDispatcher->addDeferred($unresolvable);\n\n $request = $this->createServerRequest('/');\n $middlewareDispatcher->handle($request);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":339,"symbol":"testExecutesKernelWithEmptyMiddlewareStack","kind":"method","lang":"php","code":"public function testExecutesKernelWithEmptyMiddlewareStack(): void\n {\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n $kernelProphecy->handle(Argument::type(ServerRequestInterface::class))->willReturn($responseProphecy->reveal());\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n\n $dispatcher = $this->createMiddlewareDispatcher($kernel, null);\n\n $response = $dispatcher->handle($requestProphecy->reveal());\n\n $kernelProphecy->handle(Argument::type(ServerRequestInterface::class))->shouldHaveBeenCalled();\n $this->assertSame($responseProphecy->reveal(), $response);\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":356,"symbol":"testExecutesMiddlewareLastInFirstOut","kind":"method","lang":"php","code":"public function testExecutesMiddlewareLastInFirstOut(): void\n {\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $requestProphecy->getHeader(Argument::type('string'))->willReturn([]);\n $requestProphecy->withAddedHeader(Argument::type('string'), Argument::type('string'))->will(function ($args) {\n $headers = $this->reveal()->getHeader($args[0]);\n\n $headers[] = $args[1];\n $this->getHeader($args[0])->willReturn($headers);\n $this->hasHeader($args[0])->willReturn(true);\n return $this;\n });\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy->getHeader(Argument::type('string'))->willReturn([]);\n $responseProphecy->withHeader(Argument::type('string'), Argument::type('array'))->will(function ($args) {\n $this->getHeader($args[0])->willReturn($args[1]);\n $this->hasHeader($args[0])->willReturn(true);\n return $this;\n });\n $responseProphecy->withAddedHeader(Argument::type('string'), Argument::type('string'))->will(function ($args) {\n $headers = $this->reveal()->getHeader($args[0"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":448,"symbol":"testDoesNotInstantiateDeferredMiddlewareInCaseOfAnEarlyReturningOuterMiddleware","kind":"method","lang":"php","code":"public function testDoesNotInstantiateDeferredMiddlewareInCaseOfAnEarlyReturningOuterMiddleware(): void\n {\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(Argument::cetera())->willReturn($responseProphecy->reveal());\n\n MockSequenceMiddleware::$hasBeenInstantiated = false;\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n $dispatcher = $this->createMiddlewareDispatcher($kernel, null);\n $dispatcher->addDeferred(MockSequenceMiddleware::class);\n $dispatcher->addMiddleware($middlewareProphecy->reveal());\n $response = $dispatcher->handle($requestProphecy->reveal());\n\n $this->assertFalse(MockSequenceMiddleware::$hasBeenInstantiated);\n $this->assertSame($responseProphecy->reveal(), $response);\n $kernelProphecy->handle(Argument::type(ServerRequestInterface::class))->shouldNotHaveBeenCalled();\n "} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":470,"symbol":"testThrowsExceptionForDeferredNonMiddlewareInterfaceClasses","kind":"method","lang":"php","code":"public function testThrowsExceptionForDeferredNonMiddlewareInterfaceClasses(): void\n {\n $this->expectException(RuntimeException::class);\n\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n $dispatcher = $this->createMiddlewareDispatcher($kernel, null);\n $dispatcher->addDeferred(stdClass::class);\n $dispatcher->handle($requestProphecy->reveal());\n\n $kernelProphecy->handle(Argument::type(ServerRequestInterface::class))->shouldNotHaveBeenCalled();\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":486,"symbol":"testCanBeExecutedMultipleTimes","kind":"method","lang":"php","code":"public function testCanBeExecutedMultipleTimes(): void\n {\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(Argument::cetera())->willReturn($responseProphecy->reveal());\n\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n $dispatcher = $this->createMiddlewareDispatcher($kernel, null);\n $dispatcher->add($middlewareProphecy->reveal());\n\n $response1 = $dispatcher->handle($requestProphecy->reveal());\n $response2 = $dispatcher->handle($requestProphecy->reveal());\n\n $this->assertSame($responseProphecy->reveal(), $response1);\n $this->assertSame($responseProphecy->reveal(), $response2);\n $kernelProphecy->handle(Argument::type(ServerRequestInterface::class))->shouldNotHaveBeenCalled();\n }"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":507,"symbol":"testCanBeReExecutedRecursivelyDuringDispatch","kind":"method","lang":"php","code":"public function testCanBeReExecutedRecursivelyDuringDispatch(): void\n {\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n\n $requestProphecy->hasHeader('X-NESTED')->willReturn(false);\n $requestProphecy->withAddedHeader('X-NESTED', '1')->will(function () {\n $this->hasHeader('X-NESTED')->willReturn(true);\n return $this;\n });\n\n $responseProphecy->getHeader(Argument::type('string'))->willReturn([]);\n $responseProphecy->withAddedHeader(Argument::type('string'), Argument::type('string'))->will(function ($args) {\n $headers = $this->reveal()->getHeader($args[0]);\n\n $headers[] = $args[1];\n $this->getHeader($args[0])->willReturn($headers);\n $this->hasHeader($args[0])->willReturn(true);\n return $this;\n });\n\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n $dispatcher = $this->createMiddlewareDispatcher($kernel, null);\n\n $middlewareProphe"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":556,"symbol":"testFetchesMiddlewareFromContainer","kind":"method","lang":"php","code":"public function testFetchesMiddlewareFromContainer(): void\n {\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $middlewareProphecy = $this->prophesize(MiddlewareInterface::class);\n $middlewareProphecy->process(Argument::cetera())->willReturn($responseProphecy->reveal());\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('somemiddlewarename')->willReturn(true);\n $containerProphecy->get('somemiddlewarename')->willReturn($middlewareProphecy->reveal());\n /** @var ContainerInterface $container */\n $container = $containerProphecy->reveal();\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n $dispatcher = $this->createMiddlewareDispatcher($kernel, $container);\n $dispatcher->addDeferred('somemiddlewarename');\n $response = $dispatcher->handle($requestProphecy->reveal());\n\n $this->assertSame($responseProphecy->reveal(), $response);\n $kernel"} {"repo":"slim","file":"tests/MiddlewareDispatcherTest.php","line":580,"symbol":"testMiddlewareGetsInstantiatedWithContainer","kind":"method","lang":"php","code":"public function testMiddlewareGetsInstantiatedWithContainer(): void\n {\n $kernelProphecy = $this->prophesize(RequestHandlerInterface::class);\n $requestProphecy = $this->prophesize(ServerRequestInterface::class);\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has(MockMiddlewareWithConstructor::class)->willReturn(false);\n /** @var ContainerInterface $container */\n $container = $containerProphecy->reveal();\n /** @var RequestHandlerInterface $kernel */\n $kernel = $kernelProphecy->reveal();\n $dispatcher = $this->createMiddlewareDispatcher($kernel, $container);\n $dispatcher->addDeferred(MockMiddlewareWithConstructor::class);\n $dispatcher->handle($requestProphecy->reveal());\n\n $this->assertSame($containerProphecy->reveal(), MockMiddlewareWithConstructor::$container);\n }"} {"repo":"slim","file":"tests/Mocks/CallableTest.php","line":15,"symbol":"CallableTest","kind":"class","lang":"php","code":"class CallableTest\n{\n public static $CalledCount = 0;\n\n public static $CalledContainer = null;\n\n public function __construct($container = null)\n {\n static::$CalledContainer = $container;\n }\n\n public function toCall()\n {\n static::$CalledCount++;\n\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->createResponse();\n }\n}"} {"repo":"slim","file":"tests/Mocks/CallableTest.php","line":21,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct($container = null)\n {\n static::$CalledContainer = $container;\n }"} {"repo":"slim","file":"tests/Mocks/CallableTest.php","line":26,"symbol":"toCall","kind":"method","lang":"php","code":"public function toCall()\n {\n static::$CalledCount++;\n\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->createResponse();\n }"} {"repo":"slim","file":"tests/Mocks/InvocationStrategyTest.php","line":17,"symbol":"InvocationStrategyTest","kind":"class","lang":"php","code":"class InvocationStrategyTest implements InvocationStrategyInterface\n{\n public static $LastCalledFor = null;\n\n /**\n * Invoke a route callable.\n *\n * @param callable $callable The callable to invoke using the strategy.\n * @param ServerRequestInterface $request The request object.\n * @param ResponseInterface $response The response object.\n * @param array $routeArguments The route's placeholder arguments\n *\n * @return ResponseInterface The response from the callable.\n */\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n static::$LastCalledFor = $callable;\n return $response;\n }\n}"} {"repo":"slim","file":"tests/Mocks/InvocationStrategyTest.php","line":31,"symbol":"__invoke","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request The request object. @param ResponseInterface $response The response object. @param array $routeArguments The route's placeholder arguments @return ResponseInterface The response from the callable.","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n static::$LastCalledFor = $callable;\n return $response;\n }"} {"repo":"slim","file":"tests/Mocks/InvokableTest.php","line":13,"symbol":"InvokableTest","kind":"class","lang":"php","code":"class InvokableTest\n{\n public static $CalledCount = 0;\n\n public function __invoke()\n {\n return static::$CalledCount++;\n }\n}"} {"repo":"slim","file":"tests/Mocks/InvokableTest.php","line":17,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke()\n {\n return static::$CalledCount++;\n }"} {"repo":"slim","file":"tests/Mocks/MiddlewareTest.php","line":19,"symbol":"MiddlewareTest","kind":"class","lang":"php","code":"class MiddlewareTest implements MiddlewareInterface\n{\n public static $CalledCount = 0;\n\n /**\n * {@inheritdoc}\n */\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n static::$CalledCount++;\n\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n $response = $responseFactory\n ->createResponse()\n ->withHeader('Content-Type', 'text/plain');\n $calledCount = static::$CalledCount;\n $response->getBody()->write(\"{$calledCount}\");\n\n return $response;\n }\n}"} {"repo":"slim","file":"tests/Mocks/MiddlewareTest.php","line":26,"symbol":"process","kind":"method","lang":"php","doc":"{@inheritdoc}","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n static::$CalledCount++;\n\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n $response = $responseFactory\n ->createResponse()\n ->withHeader('Content-Type', 'text/plain');\n $calledCount = static::$CalledCount;\n $response->getBody()->write(\"{$calledCount}\");\n\n return $response;\n }"} {"repo":"slim","file":"tests/Mocks/MockAction.php","line":19,"symbol":"MockAction","kind":"class","lang":"php","code":"class MockAction\n{\n public function __call($name, array $arguments)\n {\n if (count($arguments) !== 3) {\n throw new InvalidArgumentException(\"Not a Slim call\");\n }\n\n $response = $arguments[1];\n $contents = json_encode(compact('name') + ['arguments' => $arguments[2]]);\n $arguments[1]->getBody()->write($contents);\n\n return $response;\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockAction.php","line":21,"symbol":"__call","kind":"method","lang":"php","code":"public function __call($name, array $arguments)\n {\n if (count($arguments) !== 3) {\n throw new InvalidArgumentException(\"Not a Slim call\");\n }\n\n $response = $arguments[1];\n $contents = json_encode(compact('name') + ['arguments' => $arguments[2]]);\n $arguments[1]->getBody()->write($contents);\n\n return $response;\n }"} {"repo":"slim","file":"tests/Mocks/MockCustomException.php","line":15,"symbol":"MockCustomException","kind":"class","lang":"php","code":"class MockCustomException extends Exception\n{\n}"} {"repo":"slim","file":"tests/Mocks/MockCustomRequestHandlerInvocationStrategy.php","line":17,"symbol":"MockCustomRequestHandlerInvocationStrategy","kind":"class","lang":"php","code":"class MockCustomRequestHandlerInvocationStrategy implements RequestHandlerInvocationStrategyInterface\n{\n public static $CalledCount = 0;\n\n public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n self::$CalledCount += 1;\n return $callable($request);\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockCustomRequestHandlerInvocationStrategy.php","line":21,"symbol":"__invoke","kind":"method","lang":"php","code":"public function __invoke(\n callable $callable,\n ServerRequestInterface $request,\n ResponseInterface $response,\n array $routeArguments\n ): ResponseInterface {\n self::$CalledCount += 1;\n return $callable($request);\n }"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareSlimCallable.php","line":17,"symbol":"MockMiddlewareSlimCallable","kind":"class","lang":"php","code":"class MockMiddlewareSlimCallable\n{\n /**\n * @param ServerRequestInterface $request\n * @param RequestHandlerInterface $handler\n * @return ResponseInterface\n */\n public function custom(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n return $handler->handle($request);\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareSlimCallable.php","line":24,"symbol":"custom","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request @param RequestHandlerInterface $handler @return ResponseInterface","code":"public function custom(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n return $handler->handle($request);\n }"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareWithConstructor.php","line":20,"symbol":"MockMiddlewareWithConstructor","kind":"class","lang":"php","code":"class MockMiddlewareWithConstructor implements MiddlewareInterface\n{\n /**\n * @var ContainerInterface|null\n */\n public static $container;\n\n /**\n * @param ContainerInterface|null $container\n */\n public function __construct(?ContainerInterface $container = null)\n {\n self::$container = $container;\n }\n\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $prophet = new Prophet();\n $responseProphecy = $prophet->prophesize(ResponseInterface::class);\n return $responseProphecy->reveal();\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareWithConstructor.php","line":30,"symbol":"__construct","kind":"method","lang":"php","doc":"@param ContainerInterface|null $container","code":"public function __construct(?ContainerInterface $container = null)\n {\n self::$container = $container;\n }"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareWithConstructor.php","line":35,"symbol":"process","kind":"method","lang":"php","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $prophet = new Prophet();\n $responseProphecy = $prophet->prophesize(ResponseInterface::class);\n return $responseProphecy->reveal();\n }"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareWithoutConstructor.php","line":18,"symbol":"MockMiddlewareWithoutConstructor","kind":"class","lang":"php","code":"class MockMiddlewareWithoutConstructor implements MiddlewareInterface\n{\n public static $CalledCount = 0;\n\n /**\n * @param ServerRequestInterface $request\n * @param RequestHandlerInterface $handler\n * @return ResponseInterface\n */\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $appendToOutput = $request->getAttribute('appendToOutput');\n if ($appendToOutput !== null) {\n $appendToOutput('Hello World');\n }\n\n static::$CalledCount++;\n\n return $handler->handle($request);\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareWithoutConstructor.php","line":27,"symbol":"process","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request @param RequestHandlerInterface $handler @return ResponseInterface","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $appendToOutput = $request->getAttribute('appendToOutput');\n if ($appendToOutput !== null) {\n $appendToOutput('Hello World');\n }\n\n static::$CalledCount++;\n\n return $handler->handle($request);\n }"} {"repo":"slim","file":"tests/Mocks/MockMiddlewareWithoutInterface.php","line":13,"symbol":"MockMiddlewareWithoutInterface","kind":"class","lang":"php","code":"class MockMiddlewareWithoutInterface\n{\n}"} {"repo":"slim","file":"tests/Mocks/MockPsr17Factory.php","line":15,"symbol":"MockPsr17Factory","kind":"class","lang":"php","code":"class MockPsr17Factory extends Psr17Factory\n{\n protected static string $responseFactoryClass = '';\n protected static string $streamFactoryClass = '';\n protected static string $serverRequestCreatorClass = '';\n protected static string $serverRequestCreatorMethod = '';\n}"} {"repo":"slim","file":"tests/Mocks/MockPsr17FactoryWithoutStreamFactory.php","line":15,"symbol":"MockPsr17FactoryWithoutStreamFactory","kind":"class","lang":"php","code":"class MockPsr17FactoryWithoutStreamFactory extends Psr17Factory\n{\n protected static string $responseFactoryClass = 'Slim\\Psr7\\Factory\\ResponseFactory';\n protected static string $streamFactoryClass = '';\n protected static string $serverRequestCreatorClass = '';\n protected static string $serverRequestCreatorMethod = '';\n}"} {"repo":"slim","file":"tests/Mocks/MockRequestHandler.php","line":18,"symbol":"MockRequestHandler","kind":"class","lang":"php","code":"class MockRequestHandler implements RequestHandlerInterface\n{\n /**\n * @var int\n */\n private $calledCount = 0;\n\n /**\n * @param ServerRequestInterface $request\n * @return ResponseInterface\n */\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n $this->calledCount += 1;\n return $responseFactory->createResponse();\n }\n\n /**\n * @return int\n */\n public function getCalledCount(): int\n {\n return $this->calledCount;\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockRequestHandler.php","line":29,"symbol":"handle","kind":"method","lang":"php","doc":"@param ServerRequestInterface $request @return ResponseInterface","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n $this->calledCount += 1;\n return $responseFactory->createResponse();\n }"} {"repo":"slim","file":"tests/Mocks/MockRequestHandler.php","line":41,"symbol":"getCalledCount","kind":"method","lang":"php","doc":"@return int","code":"public function getCalledCount(): int\n {\n return $this->calledCount;\n }"} {"repo":"slim","file":"tests/Mocks/MockSequenceMiddleware.php","line":18,"symbol":"MockSequenceMiddleware","kind":"class","lang":"php","code":"class MockSequenceMiddleware implements MiddlewareInterface\n{\n /**\n * @var string\n */\n public static $id = '0';\n\n /**\n * @var bool\n */\n public static $hasBeenInstantiated = false;\n\n public function __construct()\n {\n static::$hasBeenInstantiated = true;\n }\n\n public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $request = $request->withAddedHeader('X-SEQ-PRE-REQ-HANDLER', static::$id);\n $response = $handler->handle($request);\n\n return $response->withAddedHeader('X-SEQ-POST-REQ-HANDLER', static::$id);\n }\n}"} {"repo":"slim","file":"tests/Mocks/MockSequenceMiddleware.php","line":30,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct()\n {\n static::$hasBeenInstantiated = true;\n }"} {"repo":"slim","file":"tests/Mocks/MockSequenceMiddleware.php","line":35,"symbol":"process","kind":"method","lang":"php","code":"public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n {\n $request = $request->withAddedHeader('X-SEQ-PRE-REQ-HANDLER', static::$id);\n $response = $handler->handle($request);\n\n return $response->withAddedHeader('X-SEQ-POST-REQ-HANDLER', static::$id);\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":36,"symbol":"MockStream","kind":"class","lang":"php","code":"class MockStream implements StreamInterface\n{\n /** @var resource A resource reference */\n private $stream;\n\n /** @var bool */\n private $seekable;\n\n /** @var bool */\n private $readable;\n\n /** @var bool */\n private $writable;\n\n /** @var array|mixed|null|void */\n private $uri;\n\n /** @var int|null */\n private $size;\n\n /** @var array Hash of readable and writable stream types */\n private static $readWriteHash = [\n 'read' => [\n 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true,\n 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true,\n 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true,\n 'x+t' => true, 'c+t' => true, 'a+' => true,\n ],\n 'write' => [\n 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true,\n 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true,\n 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true,\n 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true,\n ],\n ];\n\n /**\n * MockStream constructor.\n * @param string|resource $body\n */\n public function _"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":76,"symbol":"__construct","kind":"method","lang":"php","doc":"MockStream constructor. @param string|resource $body","code":"public function __construct($body = '')\n {\n if (is_string($body)) {\n $resource = fopen('php://temp', 'rw+');\n fwrite($resource, $body);\n $body = $resource;\n }\n\n if ('resource' === gettype($body)) {\n $this->stream = $body;\n $meta = stream_get_meta_data($this->stream);\n $this->seekable = $meta['seekable'];\n $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]);\n $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]);\n $this->uri = $this->getMetadata('uri');\n } else {\n throw new InvalidArgumentException(\n 'First argument to Stream::create() must be a string, resource or StreamInterface.'\n );\n }\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":101,"symbol":"__destruct","kind":"method","lang":"php","doc":"Closes the stream when the destructed.","code":"public function __destruct()\n {\n $this->close();\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":106,"symbol":"__toString","kind":"method","lang":"php","code":"public function __toString(): string\n {\n try {\n if ($this->isSeekable()) {\n $this->seek(0);\n }\n\n return $this->getContents();\n } catch (Exception $e) {\n return '';\n }\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":119,"symbol":"close","kind":"method","lang":"php","code":"public function close(): void\n {\n if (isset($this->stream)) {\n if (is_resource($this->stream)) {\n fclose($this->stream);\n }\n $this->detach();\n }\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":129,"symbol":"detach","kind":"method","lang":"php","code":"public function detach()\n {\n if (!isset($this->stream)) {\n return null;\n }\n\n $result = $this->stream;\n unset($this->stream);\n $this->size = $this->uri = null;\n $this->readable = $this->writable = $this->seekable = false;\n\n return $result;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":143,"symbol":"getSize","kind":"method","lang":"php","code":"public function getSize(): ?int\n {\n if (null !== $this->size) {\n return $this->size;\n }\n\n if (!isset($this->stream)) {\n return null;\n }\n\n // Clear the stat cache if the stream has a URI\n if ($this->uri) {\n clearstatcache(true, $this->uri);\n }\n\n $stats = fstat($this->stream);\n if (isset($stats['size'])) {\n $this->size = $stats['size'];\n\n return $this->size;\n }\n\n return null;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":168,"symbol":"tell","kind":"method","lang":"php","code":"public function tell(): int\n {\n if (false === $result = ftell($this->stream)) {\n throw new RuntimeException('Unable to determine stream position');\n }\n\n return $result;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":177,"symbol":"eof","kind":"method","lang":"php","code":"public function eof(): bool\n {\n return !$this->stream || feof($this->stream);\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":182,"symbol":"isSeekable","kind":"method","lang":"php","code":"public function isSeekable(): bool\n {\n return $this->seekable;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":187,"symbol":"seek","kind":"method","lang":"php","code":"public function seek($offset, $whence = SEEK_SET): void\n {\n if (!$this->seekable) {\n throw new RuntimeException('Stream is not seekable');\n }\n\n if (fseek($this->stream, $offset, $whence) === -1) {\n throw new RuntimeException(\n 'Unable to seek to stream position '\n . $offset . ' with whence ' . var_export($whence, true)\n );\n }\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":201,"symbol":"rewind","kind":"method","lang":"php","code":"public function rewind(): void\n {\n $this->seek(0);\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":206,"symbol":"isWritable","kind":"method","lang":"php","code":"public function isWritable(): bool\n {\n return $this->writable;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":211,"symbol":"write","kind":"method","lang":"php","code":"public function write($string): int\n {\n if (!$this->writable) {\n throw new RuntimeException('Cannot write to a non-writable stream');\n }\n\n // We can't know the size after writing anything\n $this->size = null;\n\n if (false === $result = fwrite($this->stream, $string)) {\n throw new RuntimeException('Unable to write to stream');\n }\n\n return $result;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":227,"symbol":"isReadable","kind":"method","lang":"php","code":"public function isReadable(): bool\n {\n return $this->readable;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":232,"symbol":"read","kind":"method","lang":"php","code":"public function read($length): string\n {\n if (!$this->readable) {\n throw new RuntimeException('Cannot read from non-readable stream');\n }\n\n return fread($this->stream, $length);\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":241,"symbol":"getContents","kind":"method","lang":"php","code":"public function getContents(): string\n {\n if (!isset($this->stream)) {\n throw new RuntimeException('Unable to read stream contents');\n }\n\n if (false === $contents = stream_get_contents($this->stream)) {\n throw new RuntimeException('Unable to read stream contents');\n }\n\n return $contents;\n }"} {"repo":"slim","file":"tests/Mocks/MockStream.php","line":254,"symbol":"getMetadata","kind":"method","lang":"php","code":"public function getMetadata($key = null)\n {\n if (!isset($this->stream)) {\n return $key ? null : [];\n }\n\n if (null === $key) {\n return stream_get_meta_data($this->stream);\n }\n\n $meta = stream_get_meta_data($this->stream);\n\n return $meta[$key] ?? null;\n }"} {"repo":"slim","file":"tests/Mocks/RequestHandlerTest.php","line":20,"symbol":"RequestHandlerTest","kind":"class","lang":"php","code":"class RequestHandlerTest implements RequestHandlerInterface\n{\n public static $CalledCount = 0;\n public static $strategy = '';\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n static::$CalledCount++;\n\n // store the strategy that was used to call this handler - it's in the back trace\n $trace = debug_backtrace();\n if (isset($trace[1])) {\n static::$strategy = $trace[1]['class'];\n }\n\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n $response = $responseFactory\n ->createResponse()\n ->withHeader('Content-Type', 'text/plain');\n $calledCount = static::$CalledCount;\n $response->getBody()->write(\"{$calledCount}\");\n\n return $response;\n }\n\n public function custom(ServerRequestInterface $request): ResponseInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n return $responseFactory->createResponse();\n }\n}"} {"repo":"slim","file":"tests/Mocks/RequestHandlerTest.php","line":25,"symbol":"handle","kind":"method","lang":"php","code":"public function handle(ServerRequestInterface $request): ResponseInterface\n {\n static::$CalledCount++;\n\n // store the strategy that was used to call this handler - it's in the back trace\n $trace = debug_backtrace();\n if (isset($trace[1])) {\n static::$strategy = $trace[1]['class'];\n }\n\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n $response = $responseFactory\n ->createResponse()\n ->withHeader('Content-Type', 'text/plain');\n $calledCount = static::$CalledCount;\n $response->getBody()->write(\"{$calledCount}\");\n\n return $response;\n }"} {"repo":"slim","file":"tests/Mocks/RequestHandlerTest.php","line":47,"symbol":"custom","kind":"method","lang":"php","code":"public function custom(ServerRequestInterface $request): ResponseInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n $responseFactory = $psr7ObjectProvider->getResponseFactory();\n\n return $responseFactory->createResponse();\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":22,"symbol":"SlowPokeStream","kind":"class","lang":"php","code":"class SlowPokeStream implements StreamInterface\n{\n public const CHUNK_SIZE = 1;\n public const SIZE = 500;\n\n /**\n * @var int\n */\n private $amountToRead;\n\n public function __construct()\n {\n $this->amountToRead = self::SIZE;\n }\n\n public function __toString(): string\n {\n $content = '';\n while (!$this->eof()) {\n $content .= $this->read(self::CHUNK_SIZE);\n }\n return $content;\n }\n\n public function close(): void\n {\n }\n\n public function detach()\n {\n throw new Exception('not implemented');\n }\n\n public function eof(): bool\n {\n return $this->amountToRead === 0;\n }\n\n public function getContents(): string\n {\n throw new Exception('not implemented');\n }\n\n public function getMetadata($key = null)\n {\n throw new Exception('not implemented');\n }\n\n public function getSize(): ?int\n {\n return null;\n }\n\n public function isReadable(): bool\n {\n return true;\n }\n\n public function isSeekable(): bool\n {\n return false;\n }\n\n public function isWritable(): bool\n {\n return false;\n }\n\n public func"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":32,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct()\n {\n $this->amountToRead = self::SIZE;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":37,"symbol":"__toString","kind":"method","lang":"php","code":"public function __toString(): string\n {\n $content = '';\n while (!$this->eof()) {\n $content .= $this->read(self::CHUNK_SIZE);\n }\n return $content;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":46,"symbol":"close","kind":"method","lang":"php","code":"public function close(): void\n {\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":50,"symbol":"detach","kind":"method","lang":"php","code":"public function detach()\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":55,"symbol":"eof","kind":"method","lang":"php","code":"public function eof(): bool\n {\n return $this->amountToRead === 0;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":60,"symbol":"getContents","kind":"method","lang":"php","code":"public function getContents(): string\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":65,"symbol":"getMetadata","kind":"method","lang":"php","code":"public function getMetadata($key = null)\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":70,"symbol":"getSize","kind":"method","lang":"php","code":"public function getSize(): ?int\n {\n return null;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":75,"symbol":"isReadable","kind":"method","lang":"php","code":"public function isReadable(): bool\n {\n return true;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":80,"symbol":"isSeekable","kind":"method","lang":"php","code":"public function isSeekable(): bool\n {\n return false;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":85,"symbol":"isWritable","kind":"method","lang":"php","code":"public function isWritable(): bool\n {\n return false;\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":90,"symbol":"read","kind":"method","lang":"php","code":"public function read($length): string\n {\n usleep(1);\n $size = min($this->amountToRead, self::CHUNK_SIZE, $length);\n $this->amountToRead -= $size;\n return str_repeat('.', $size);\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":98,"symbol":"rewind","kind":"method","lang":"php","code":"public function rewind(): void\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":103,"symbol":"seek","kind":"method","lang":"php","code":"public function seek($offset, $whence = SEEK_SET): void\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":108,"symbol":"tell","kind":"method","lang":"php","code":"public function tell(): int\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SlowPokeStream.php","line":113,"symbol":"write","kind":"method","lang":"php","code":"public function write($string): int\n {\n return strlen($string);\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":21,"symbol":"SmallChunksStream","kind":"class","lang":"php","code":"class SmallChunksStream implements StreamInterface\n{\n public const CHUNK_SIZE = 10;\n public const SIZE = 40;\n\n /**\n * @var int\n */\n private $amountToRead;\n\n public function __construct()\n {\n $this->amountToRead = self::SIZE;\n }\n\n public function __toString(): string\n {\n return str_repeat('.', self::SIZE);\n }\n\n public function close(): void\n {\n }\n\n public function detach()\n {\n throw new Exception('not implemented');\n }\n\n public function eof(): bool\n {\n return $this->amountToRead === 0;\n }\n\n public function getContents(): string\n {\n throw new Exception('not implemented');\n }\n\n public function getMetadata($key = null)\n {\n throw new Exception('not implemented');\n }\n\n public function getSize(): ?int\n {\n return self::SIZE;\n }\n\n public function isReadable(): bool\n {\n return true;\n }\n\n public function isSeekable(): bool\n {\n return false;\n }\n\n public function isWritable(): bool\n {\n return false;\n }\n\n public function read($length): string\n {\n $size = min($this->amountToRead, self::CHUNK_SIZE, "} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":31,"symbol":"__construct","kind":"method","lang":"php","code":"public function __construct()\n {\n $this->amountToRead = self::SIZE;\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":36,"symbol":"__toString","kind":"method","lang":"php","code":"public function __toString(): string\n {\n return str_repeat('.', self::SIZE);\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":41,"symbol":"close","kind":"method","lang":"php","code":"public function close(): void\n {\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":45,"symbol":"detach","kind":"method","lang":"php","code":"public function detach()\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":50,"symbol":"eof","kind":"method","lang":"php","code":"public function eof(): bool\n {\n return $this->amountToRead === 0;\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":55,"symbol":"getContents","kind":"method","lang":"php","code":"public function getContents(): string\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":60,"symbol":"getMetadata","kind":"method","lang":"php","code":"public function getMetadata($key = null)\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":65,"symbol":"getSize","kind":"method","lang":"php","code":"public function getSize(): ?int\n {\n return self::SIZE;\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":70,"symbol":"isReadable","kind":"method","lang":"php","code":"public function isReadable(): bool\n {\n return true;\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":75,"symbol":"isSeekable","kind":"method","lang":"php","code":"public function isSeekable(): bool\n {\n return false;\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":80,"symbol":"isWritable","kind":"method","lang":"php","code":"public function isWritable(): bool\n {\n return false;\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":85,"symbol":"read","kind":"method","lang":"php","code":"public function read($length): string\n {\n $size = min($this->amountToRead, self::CHUNK_SIZE, $length);\n $this->amountToRead -= $size;\n\n return str_repeat('.', min($length, $size));\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":93,"symbol":"rewind","kind":"method","lang":"php","code":"public function rewind(): void\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":98,"symbol":"seek","kind":"method","lang":"php","code":"public function seek($offset, $whence = SEEK_SET): void\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":103,"symbol":"tell","kind":"method","lang":"php","code":"public function tell(): int\n {\n throw new Exception('not implemented');\n }"} {"repo":"slim","file":"tests/Mocks/SmallChunksStream.php","line":108,"symbol":"write","kind":"method","lang":"php","code":"public function write($string): int\n {\n return strlen($string);\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":30,"symbol":"PSR7ObjectProvider","kind":"class","lang":"php","doc":"Class PSR7ObjectProvider @package Slim\\Tests\\Providers","code":"class PSR7ObjectProvider implements PSR7ObjectProviderInterface\n{\n /**\n * @param string $uri\n * @param string $method\n * @param array $data\n * @return ServerRequestInterface\n */\n public function createServerRequest(\n string $uri,\n string $method = 'GET',\n array $data = []\n ): ServerRequestInterface {\n $headers = array_merge([\n 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',\n 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',\n 'HTTP_HOST' => 'localhost',\n 'HTTP_USER_AGENT' => 'Slim Framework',\n 'QUERY_STRING' => '',\n 'REMOTE_ADDR' => '127.0.0.1',\n 'REQUEST_METHOD' => $method,\n 'REQUEST_TIME' => time(),\n 'REQUEST_TIME_FLOAT' => microtime(true),\n 'REQUEST_URI' => '',\n 'SCRIPT_NAME' => '/index.php',\n 'SERVER_NAME' => 'localhost',\n 'SERVER_PORT' => 80,\n 'SERVER_PROTOCOL' => 'HTTP/1.1',\n ], $data);\n\n return $this\n ->getServerRequestFactory()\n ->c"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":38,"symbol":"createServerRequest","kind":"method","lang":"php","doc":"@param string $uri @param string $method @param array $data @return ServerRequestInterface","code":"public function createServerRequest(\n string $uri,\n string $method = 'GET',\n array $data = []\n ): ServerRequestInterface {\n $headers = array_merge([\n 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',\n 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',\n 'HTTP_HOST' => 'localhost',\n 'HTTP_USER_AGENT' => 'Slim Framework',\n 'QUERY_STRING' => '',\n 'REMOTE_ADDR' => '127.0.0.1',\n 'REQUEST_METHOD' => $method,\n 'REQUEST_TIME' => time(),\n 'REQUEST_TIME_FLOAT' => microtime(true),\n 'REQUEST_URI' => '',\n 'SCRIPT_NAME' => '/index.php',\n 'SERVER_NAME' => 'localhost',\n 'SERVER_PORT' => 80,\n 'SERVER_PROTOCOL' => 'HTTP/1.1',\n ], $data);\n\n return $this\n ->getServerRequestFactory()\n ->createServerRequest($method, $uri, $headers);\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":69,"symbol":"getServerRequestFactory","kind":"method","lang":"php","doc":"@return ServerRequestFactoryInterface","code":"public function getServerRequestFactory(): ServerRequestFactoryInterface\n {\n return new Psr17Factory();\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":79,"symbol":"createResponse","kind":"method","lang":"php","doc":"@param int $statusCode @param string $reasonPhrase @return ResponseInterface","code":"public function createResponse(int $statusCode = 200, string $reasonPhrase = ''): ResponseInterface\n {\n return $this\n ->getResponseFactory()\n ->createResponse($statusCode, $reasonPhrase);\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":89,"symbol":"getResponseFactory","kind":"method","lang":"php","doc":"@return ResponseFactoryInterface","code":"public function getResponseFactory(): ResponseFactoryInterface\n {\n return new Psr17Factory();\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":98,"symbol":"createStream","kind":"method","lang":"php","doc":"@param string $contents @return StreamInterface","code":"public function createStream(string $contents = ''): StreamInterface\n {\n return $this\n ->getStreamFactory()\n ->createStream($contents);\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProvider.php","line":108,"symbol":"getStreamFactory","kind":"method","lang":"php","doc":"@return StreamFactoryInterface","code":"public function getStreamFactory(): StreamFactoryInterface\n {\n return new Psr17Factory();\n }"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":25,"symbol":"PSR7ObjectProviderInterface","kind":"interface","lang":"php","doc":"Interface PSR7ObjectProviderInterface @package Slim\\Tests\\Providers","code":"interface PSR7ObjectProviderInterface\n{\n /**\n * @return ServerRequestFactoryInterface\n */\n public function getServerRequestFactory(): ServerRequestFactoryInterface;\n\n /**\n * @return ResponseFactoryInterface\n */\n public function getResponseFactory(): ResponseFactoryInterface;\n\n /**\n * @return StreamFactoryInterface\n */\n public function getStreamFactory(): StreamFactoryInterface;\n\n /**\n * @param string $uri\n * @param string $method\n * @param array $data\n * @return ServerRequestInterface\n */\n public function createServerRequest(string $uri, string $method = 'GET', array $data = []): ServerRequestInterface;\n\n /**\n * @param int $statusCode\n * @param string $reasonPhrase\n * @return ResponseInterface\n */\n public function createResponse(int $statusCode = 200, string $reasonPhrase = ''): ResponseInterface;\n\n /**\n * @param string $contents\n * @return StreamInterface\n */\n public function createStream(string $contents = ''): StreamInterface;\n}"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":30,"symbol":"getServerRequestFactory","kind":"method","lang":"php","doc":"@return ServerRequestFactoryInterface","code":"public function getServerRequestFactory(): ServerRequestFactoryInterface;"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":35,"symbol":"getResponseFactory","kind":"method","lang":"php","doc":"@return ResponseFactoryInterface","code":"public function getResponseFactory(): ResponseFactoryInterface;"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":40,"symbol":"getStreamFactory","kind":"method","lang":"php","doc":"@return StreamFactoryInterface","code":"public function getStreamFactory(): StreamFactoryInterface;"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":48,"symbol":"createServerRequest","kind":"method","lang":"php","doc":"@param string $uri @param string $method @param array $data @return ServerRequestInterface","code":"public function createServerRequest(string $uri, string $method = 'GET', array $data = []): ServerRequestInterface;"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":55,"symbol":"createResponse","kind":"method","lang":"php","doc":"@param int $statusCode @param string $reasonPhrase @return ResponseInterface","code":"public function createResponse(int $statusCode = 200, string $reasonPhrase = ''): ResponseInterface;"} {"repo":"slim","file":"tests/Providers/PSR7ObjectProviderInterface.php","line":61,"symbol":"createStream","kind":"method","lang":"php","doc":"@param string $contents @return StreamInterface","code":"public function createStream(string $contents = ''): StreamInterface;"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":38,"symbol":"ResponseEmitterTest","kind":"class","lang":"php","code":"class ResponseEmitterTest extends TestCase\n{\n public function setUp(): void\n {\n HeaderStack::reset();\n }\n\n public function tearDown(): void\n {\n HeaderStack::reset();\n }\n\n public function testRespond(): void\n {\n $response = $this->createResponse();\n $response->getBody()->write('Hello');\n\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $this->expectOutputString('Hello');\n }\n\n public function testRespondWithPaddedStreamFilterOutput(): void\n {\n $availableFilter = stream_get_filters();\n\n $filterName = 'string.rot13';\n $unfilterName = 'string.rot13';\n $specificFilterName = 'string.rot13';\n $specificUnfilterName = 'string.rot13';\n\n if (in_array($filterName, $availableFilter) && in_array($unfilterName, $availableFilter)) {\n $key = base64_decode('xxxxxxxxxxxxxxxx');\n $iv = base64_decode('Z6wNDk9LogWI4HYlRu0mng==');\n\n $data = 'Hello';\n $length = strlen($data);\n\n $stream = fopen('php://temp', 'r+');\n $filter = stream_filter_append($stream, $specificFilterName, STREAM_FILTER"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":40,"symbol":"setUp","kind":"method","lang":"php","code":"public function setUp(): void\n {\n HeaderStack::reset();\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":45,"symbol":"tearDown","kind":"method","lang":"php","code":"public function tearDown(): void\n {\n HeaderStack::reset();\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":50,"symbol":"testRespond","kind":"method","lang":"php","code":"public function testRespond(): void\n {\n $response = $this->createResponse();\n $response->getBody()->write('Hello');\n\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $this->expectOutputString('Hello');\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":61,"symbol":"testRespondWithPaddedStreamFilterOutput","kind":"method","lang":"php","code":"public function testRespondWithPaddedStreamFilterOutput(): void\n {\n $availableFilter = stream_get_filters();\n\n $filterName = 'string.rot13';\n $unfilterName = 'string.rot13';\n $specificFilterName = 'string.rot13';\n $specificUnfilterName = 'string.rot13';\n\n if (in_array($filterName, $availableFilter) && in_array($unfilterName, $availableFilter)) {\n $key = base64_decode('xxxxxxxxxxxxxxxx');\n $iv = base64_decode('Z6wNDk9LogWI4HYlRu0mng==');\n\n $data = 'Hello';\n $length = strlen($data);\n\n $stream = fopen('php://temp', 'r+');\n $filter = stream_filter_append($stream, $specificFilterName, STREAM_FILTER_WRITE, [\n 'key' => $key,\n 'iv' => $iv\n ]);\n\n fwrite($stream, $data);\n rewind($stream);\n stream_filter_remove($filter);\n stream_filter_append($stream, $specificUnfilterName, STREAM_FILTER_READ, [\n 'key' => $key,\n 'iv' => $iv\n ]);\n\n $body = $this->getStreamFactory()->createStreamFromResource($stream);\n $response = $this\n ->cr"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":106,"symbol":"testRespondIndeterminateLength","kind":"method","lang":"php","code":"public function testRespondIndeterminateLength(): void\n {\n $stream = fopen('php://temp', 'r+');\n fwrite($stream, 'Hello');\n rewind($stream);\n\n $body = $this\n ->getMockBuilder(MockStream::class)\n ->setConstructorArgs([$stream])\n ->onlyMethods(['getSize'])\n ->getMock();\n $body->method('getSize')->willReturn(null);\n\n $response = $this->createResponse()->withBody($body);\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $this->expectOutputString('Hello');\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":126,"symbol":"testResponseWithStreamReadYieldingLessBytesThanAsked","kind":"method","lang":"php","code":"public function testResponseWithStreamReadYieldingLessBytesThanAsked(): void\n {\n $body = new SmallChunksStream();\n $response = $this->createResponse()->withBody($body);\n\n $responseEmitter = new ResponseEmitter($body::CHUNK_SIZE * 2);\n $responseEmitter->emit($response);\n\n $this->expectOutputString(str_repeat('.', $body->getSize()));\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":137,"symbol":"testResponseReplacesPreviouslySetHeaders","kind":"method","lang":"php","code":"public function testResponseReplacesPreviouslySetHeaders(): void\n {\n $response = $this\n ->createResponse(200, 'OK')\n ->withHeader('X-Foo', 'baz1')\n ->withAddedHeader('X-Foo', 'baz2');\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $expectedStack = [\n ['header' => 'X-Foo: baz1', 'replace' => true, 'status_code' => null],\n ['header' => 'X-Foo: baz2', 'replace' => false, 'status_code' => null],\n ['header' => 'HTTP/1.1 200 OK', 'replace' => true, 'status_code' => 200],\n ];\n\n $this->assertSame($expectedStack, HeaderStack::stack());\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":155,"symbol":"testResponseDoesNotReplacePreviouslySetSetCookieHeaders","kind":"method","lang":"php","code":"public function testResponseDoesNotReplacePreviouslySetSetCookieHeaders(): void\n {\n $response = $this\n ->createResponse(200, 'OK')\n ->withHeader('set-cOOkie', 'foo=bar')\n ->withAddedHeader('Set-Cookie', 'bar=baz');\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $expectedStack = [\n ['header' => 'set-cOOkie: foo=bar', 'replace' => false, 'status_code' => null],\n ['header' => 'set-cOOkie: bar=baz', 'replace' => false, 'status_code' => null],\n ['header' => 'HTTP/1.1 200 OK', 'replace' => true, 'status_code' => 200],\n ];\n\n $this->assertSame($expectedStack, HeaderStack::stack());\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":173,"symbol":"testIsResponseEmptyWithNonEmptyBodyAndTriggeringStatusCode","kind":"method","lang":"php","code":"public function testIsResponseEmptyWithNonEmptyBodyAndTriggeringStatusCode(): void\n {\n $body = $this->createStream('Hello');\n $response = $this\n ->createResponse(204)\n ->withBody($body);\n $responseEmitter = new ResponseEmitter();\n\n $this->assertTrue($responseEmitter->isResponseEmpty($response));\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":184,"symbol":"testIsResponseEmptyDoesNotReadAllDataFromNonEmptySeekableResponse","kind":"method","lang":"php","code":"public function testIsResponseEmptyDoesNotReadAllDataFromNonEmptySeekableResponse(): void\n {\n $body = $this->createStream('Hello');\n $response = $this\n ->createResponse(200)\n ->withBody($body);\n $responseEmitter = new ResponseEmitter();\n\n $responseEmitter->isResponseEmpty($response);\n\n $this->assertTrue($body->isSeekable());\n $this->assertFalse($body->eof());\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":198,"symbol":"testIsResponseEmptyDoesNotDrainNonSeekableResponseWithContent","kind":"method","lang":"php","code":"public function testIsResponseEmptyDoesNotDrainNonSeekableResponseWithContent(): void\n {\n $resource = popen('echo 12', 'r');\n $body = $this->getStreamFactory()->createStreamFromResource($resource);\n $response = $this->createResponse(200)->withBody($body);\n $responseEmitter = new ResponseEmitter();\n\n $responseEmitter->isResponseEmpty($response);\n\n $this->assertFalse($body->isSeekable());\n $this->assertSame('12', trim((string) $body));\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":211,"symbol":"testAvoidReadFromSlowStreamAccordingToStatus","kind":"method","lang":"php","code":"public function testAvoidReadFromSlowStreamAccordingToStatus(): void\n {\n $body = new SlowPokeStream();\n $response = $this\n ->createResponse(204, 'No content')\n ->withBody($body);\n\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $this->assertFalse($body->eof());\n $this->expectOutputString('');\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":225,"symbol":"testIsResponseEmptyWithEmptyBody","kind":"method","lang":"php","code":"public function testIsResponseEmptyWithEmptyBody(): void\n {\n $response = $this->createResponse(200);\n $responseEmitter = new ResponseEmitter();\n\n $this->assertTrue($responseEmitter->isResponseEmpty($response));\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":233,"symbol":"testIsResponseEmptyWithZeroAsBody","kind":"method","lang":"php","code":"public function testIsResponseEmptyWithZeroAsBody(): void\n {\n $body = $this->createStream('0');\n $response = $this\n ->createResponse(200)\n ->withBody($body);\n $responseEmitter = new ResponseEmitter();\n\n $this->assertFalse($responseEmitter->isResponseEmpty($response));\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":244,"symbol":"testWillHandleInvalidConnectionStatusWithADeterminateBody","kind":"method","lang":"php","code":"public function testWillHandleInvalidConnectionStatusWithADeterminateBody(): void\n {\n $body = $this->getStreamFactory()->createStreamFromResource(fopen('php://temp', 'r+'));\n $body->write('Hello!' . \"\\n\");\n $body->write('Hello!' . \"\\n\");\n\n // Tell connection_status() to fail.\n $GLOBALS['connection_status_return'] = CONNECTION_ABORTED;\n\n $response = $this\n ->createResponse()\n ->withHeader('Content-Length', $body->getSize())\n ->withBody($body);\n\n $responseEmitter = new ResponseEmitter();\n $responseEmitter->emit($response);\n\n $this->expectOutputString(\"Hello!\\nHello!\\n\");\n\n // Tell connection_status() to pass.\n unset($GLOBALS['connection_status_return']);\n }"} {"repo":"slim","file":"tests/ResponseEmitterTest.php","line":267,"symbol":"testWillHandleInvalidConnectionStatusWithAnIndeterminateBody","kind":"method","lang":"php","code":"public function testWillHandleInvalidConnectionStatusWithAnIndeterminateBody(): void\n {\n $body = $this->getStreamFactory()->createStreamFromResource(fopen('php://input', 'r+'));\n\n // Tell connection_status() to fail.\n $GLOBALS['connection_status_return'] = CONNECTION_TIMEOUT;\n\n $response = $this\n ->createResponse()\n ->withBody($body);\n\n\n $responseEmitter = new ResponseEmitter();\n\n $mirror = new ReflectionClass(ResponseEmitter::class);\n $emitBodyMethod = $mirror->getMethod('emitBody');\n $this->setAccessible($emitBodyMethod);\n $emitBodyMethod->invoke($responseEmitter, $response);\n\n $this->expectOutputString(\"\");\n\n // Tell connection_status() to pass.\n unset($GLOBALS['connection_status_return']);\n }"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":28,"symbol":"DispatcherTest","kind":"class","lang":"php","code":"class DispatcherTest extends TestCase\n{\n public function testCreateDispatcher()\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $dispatcher = new Dispatcher($routeCollector);\n\n $method = new ReflectionMethod(Dispatcher::class, 'createDispatcher');\n $this->setAccessible($method);\n\n $this->assertInstanceOf(FastRouteDispatcher::class, $method->invoke($dispatcher));\n }\n\n /**\n * Test cached routes file is created & that it holds our routes.\n */\n public function testRouteCacheFileCanBeDispatched()\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $dispatcher = new Dispatcher($routeCollector);\n\n $route = $routeCollector->map(['GET'"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":30,"symbol":"testCreateDispatcher","kind":"method","lang":"php","code":"public function testCreateDispatcher()\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $dispatcher = new Dispatcher($routeCollector);\n\n $method = new ReflectionMethod(Dispatcher::class, 'createDispatcher');\n $this->setAccessible($method);\n\n $this->assertInstanceOf(FastRouteDispatcher::class, $method->invoke($dispatcher));\n }"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":46,"symbol":"testRouteCacheFileCanBeDispatched","kind":"method","lang":"php","doc":"Test cached routes file is created & that it holds our routes.","code":"public function testRouteCacheFileCanBeDispatched()\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $dispatcher = new Dispatcher($routeCollector);\n\n $route = $routeCollector->map(['GET'], '/', function () {\n });\n $route->setName('foo');\n\n $cacheFile = __DIR__ . '/' . uniqid((string) microtime(true));\n $routeCollector->setCacheFile($cacheFile);\n\n $method = new ReflectionMethod(Dispatcher::class, 'createDispatcher');\n $this->setAccessible($method);\n $method->invoke($dispatcher);\n $this->assertFileExists($cacheFile, 'cache file was not created');\n\n $routeCollector2 = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector2->setCacheFile($cacheFile);\n $dispatcher2 = new Dispatcher($routeCollector2);\n\n $method = new ReflectionMethod(Dispatcher::class, 'createDispatcher');\n $this->s"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":84,"symbol":"testCreateDispatcherReturnsSameDispatcherASecondTime","kind":"method","lang":"php","doc":"Calling createDispatcher as second time should give you back the same dispatcher as when you called it the first time.","code":"public function testCreateDispatcherReturnsSameDispatcherASecondTime()\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $dispatcher = new Dispatcher($routeCollector);\n\n $method = new ReflectionMethod(Dispatcher::class, 'createDispatcher');\n $this->setAccessible($method);\n\n $fastRouteDispatcher = $method->invoke($dispatcher);\n $fastRouteDispatcher2 = $method->invoke($dispatcher);\n\n $this->assertSame($fastRouteDispatcher, $fastRouteDispatcher2);\n }"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":100,"symbol":"testGetAllowedMethods","kind":"method","lang":"php","code":"public function testGetAllowedMethods()\n {\n $methods = ['GET', 'POST', 'PUT'];\n $uri = '/';\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->map($methods, $uri, function () {\n });\n\n $dispatcher = new Dispatcher($routeCollector);\n $results = $dispatcher->getAllowedMethods('/');\n\n $this->assertSame($methods, $results);\n }"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":118,"symbol":"testDispatch","kind":"method","lang":"php","code":"public function testDispatch()\n {\n $methods = ['GET', 'POST'];\n $uri = '/hello/{name}';\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n $callable = function () {\n };\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $route = $routeCollector->map($methods, $uri, $callable);\n\n $dispatcher = new Dispatcher($routeCollector);\n $results = $dispatcher->dispatch('GET', '/hello/Foo%20Bar');\n\n $this->assertSame(RoutingResults::FOUND, $results->getRouteStatus());\n $this->assertSame('GET', $results->getMethod());\n $this->assertSame('/hello/Foo%20Bar', $results->getUri());\n $this->assertSame($route->getIdentifier(), $results->getRouteIdentifier());\n $this->assertSame(['name' => 'Foo%20Bar'], $results->getRouteArguments());\n $this->assertSame(['name' => 'Foo%20Bar'], $results->getRouteArguments(false));\n $this->assertSame($methods, $results->getAllowedMethods());\n $this->assertSame($dispatche"} {"repo":"slim","file":"tests/Routing/DispatcherTest.php","line":144,"symbol":"testRouteArgumentsAreDecodedOnlyOnce","kind":"method","lang":"php","code":"public function testRouteArgumentsAreDecodedOnlyOnce()\n {\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n $callable = function () {\n };\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->map(['GET'], '/download/{file}', $callable);\n\n $routeResolver = new RouteResolver($routeCollector);\n\n $results = $routeResolver->computeRoutingResults('/download/Foo%20Bar', 'GET');\n $this->assertSame(RoutingResults::FOUND, $results->getRouteStatus());\n $this->assertSame(['file' => 'Foo Bar'], $results->getRouteArguments());\n\n $results = $routeResolver->computeRoutingResults('/download/%252e%252e%252fetc%252fpasswd', 'GET');\n $this->assertSame(RoutingResults::FOUND, $results->getRouteStatus());\n $this->assertSame(['file' => '%2e%2e%2fetc%2fpasswd'], $results->getRouteArguments());\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":21,"symbol":"FastRouteDispatcherTest","kind":"class","lang":"php","code":"class FastRouteDispatcherTest extends TestCase\n{\n /**\n * @dataProvider provideFoundDispatchCases\n */\n #[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideFoundDispatchCases')]\n public function testFoundDispatches($method, $uri, $callback, $handler, $argDict)\n {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());\n\n $results = $dispatcher->dispatch($method, $uri);\n\n $this->assertSame($dispatcher::FOUND, $results[0]);\n $this->assertSame($handler, $results[1]);\n $this->assertSame($argDict, $results[2]);\n }\n\n /**\n * Set appropriate options for the specific Dispatcher class we're testing\n */\n private function generateDispatcherOptions()\n {\n return [\n 'dataGenerator' => $this->getDataGeneratorClass(),\n 'dispatcher' => $this->getDispatcherClass()\n ];\n }\n\n protected function getDataGeneratorClass()\n {\n return GroupCountBased::class;\n }\n\n protected function getDispatcherClass()\n {\n return FastRouteDispatcher::class;\n }\n\n /**\n * @dataProvider provideNotFoundDispa"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":26,"symbol":"testFoundDispatches","kind":"method","lang":"php","doc":"@dataProvider provideFoundDispatchCases","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideFoundDispatchCases')]\n public function testFoundDispatches($method, $uri, $callback, $handler, $argDict)\n {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());\n\n $results = $dispatcher->dispatch($method, $uri);\n\n $this->assertSame($dispatcher::FOUND, $results[0]);\n $this->assertSame($handler, $results[1]);\n $this->assertSame($argDict, $results[2]);\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":42,"symbol":"generateDispatcherOptions","kind":"method","lang":"php","doc":"Set appropriate options for the specific Dispatcher class we're testing","code":"private function generateDispatcherOptions()\n {\n return [\n 'dataGenerator' => $this->getDataGeneratorClass(),\n 'dispatcher' => $this->getDispatcherClass()\n ];\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":50,"symbol":"getDataGeneratorClass","kind":"method","lang":"php","code":"protected function getDataGeneratorClass()\n {\n return GroupCountBased::class;\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":55,"symbol":"getDispatcherClass","kind":"method","lang":"php","code":"protected function getDispatcherClass()\n {\n return FastRouteDispatcher::class;\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":63,"symbol":"testNotFoundDispatches","kind":"method","lang":"php","doc":"@dataProvider provideNotFoundDispatchCases","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideNotFoundDispatchCases')]\n public function testNotFoundDispatches($method, $uri, $callback)\n {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());\n\n $results = $dispatcher->dispatch($method, $uri);\n\n $this->assertSame($dispatcher::NOT_FOUND, $results[0]);\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":81,"symbol":"testMethodNotAllowedDispatches","kind":"method","lang":"php","doc":"@dataProvider provideMethodNotAllowedDispatchCases @param $method @param $uri @param $callback @param $allowedMethods","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideMethodNotAllowedDispatchCases')]\n public function testMethodNotAllowedDispatches($method, $uri, $callback, $allowedMethods)\n {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());\n\n $results = $dispatcher->dispatch($method, $uri);\n\n $this->assertSame($dispatcher::METHOD_NOT_ALLOWED, $results[0]);\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":99,"symbol":"testGetAllowedMethods","kind":"method","lang":"php","doc":"@dataProvider provideMethodNotAllowedDispatchCases @param $method @param $uri @param $callback @param $allowedMethods","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('provideMethodNotAllowedDispatchCases')]\n public function testGetAllowedMethods($method, $uri, $callback, $allowedMethods)\n {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());\n\n $results = $dispatcher->getAllowedMethods($uri);\n\n $this->assertSame($results, $allowedMethods);\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":110,"symbol":"testGetAllowedMethodsReusesLastUriOnly","kind":"method","lang":"php","code":"public function testGetAllowedMethodsReusesLastUriOnly()\n {\n /** @var FastRouteDispatcher $dispatcher */\n $dispatcher = simpleDispatcher(function (RouteCollector $r) {\n $r->addRoute('GET', '/user', 'handler0');\n $r->addRoute('POST', '/post', 'handler1');\n }, $this->generateDispatcherOptions());\n\n $this->assertSame(['GET'], $dispatcher->getAllowedMethods('/user'));\n $this->assertSame(['POST'], $dispatcher->getAllowedMethods('/post'));\n\n // Repeating the first URI recomputes, as only the last result is kept.\n $this->assertSame(['GET'], $dispatcher->getAllowedMethods('/user'));\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":125,"symbol":"testDuplicateVariableNameError","kind":"method","lang":"php","code":"public function testDuplicateVariableNameError()\n {\n $this->expectException(BadRouteException::class);\n $this->expectExceptionMessage('Cannot use the same placeholder \"test\" twice');\n\n simpleDispatcher(function (RouteCollector $r) {\n $r->addRoute('GET', '/foo/{test}/{test:\\d+}', 'handler0');\n }, $this->generateDispatcherOptions());\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":135,"symbol":"testDuplicateVariableRoute","kind":"method","lang":"php","code":"public function testDuplicateVariableRoute()\n {\n $this->expectException(BadRouteException::class);\n $this->expectExceptionMessage('Cannot register two routes matching \"/user/([^/]+)\" for method \"GET\"');\n\n simpleDispatcher(function (RouteCollector $r) {\n $r->addRoute('GET', '/user/{id}', 'handler0'); // oops, forgot \\d+ restriction ;)\n $r->addRoute('GET', '/user/{name}', 'handler1');\n }, $this->generateDispatcherOptions());\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":146,"symbol":"testDuplicateStaticRoute","kind":"method","lang":"php","code":"public function testDuplicateStaticRoute()\n {\n $this->expectException(BadRouteException::class);\n $this->expectExceptionMessage('Cannot register two routes matching \"/user\" for method \"GET\"');\n\n simpleDispatcher(function (RouteCollector $r) {\n $r->addRoute('GET', '/user', 'handler0');\n $r->addRoute('GET', '/user', 'handler1');\n }, $this->generateDispatcherOptions());\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":161,"symbol":"testShadowedStaticRoute","kind":"method","lang":"php","doc":"@codingStandardsIgnoreStart @codingStandardsIgnoreEnd","code":"public function testShadowedStaticRoute()\n {\n $this->expectException(BadRouteException::class);\n $this->expectExceptionMessage('Static route \"/user/nikic\" is shadowed by previously defined variable route' .\n ' \"/user/([^/]+)\" for method \"GET\"');\n\n simpleDispatcher(function (RouteCollector $r) {\n $r->addRoute('GET', '/user/{name}', 'handler0');\n $r->addRoute('GET', '/user/nikic', 'handler1');\n }, $this->generateDispatcherOptions());\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":173,"symbol":"testCapturing","kind":"method","lang":"php","code":"public function testCapturing()\n {\n $this->expectException(BadRouteException::class);\n $this->expectExceptionMessage('Regex \"(en|de)\" for parameter \"lang\" contains a capturing group');\n\n simpleDispatcher(function (RouteCollector $r) {\n $r->addRoute('GET', '/{lang:(en|de)}', 'handler0');\n }, $this->generateDispatcherOptions());\n }"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":183,"symbol":"provideFoundDispatchCases","kind":"method","lang":"php","code":"public static function provideFoundDispatchCases()\n {\n $cases = [];\n\n // 0 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/resource/123/456', 'handler0');\n };\n\n $method = 'GET';\n $uri = '/resource/123/456';\n $handler = 'handler0';\n $argDict = [];\n\n $cases[] = [$method, $uri, $callback, $handler, $argDict];\n\n // 1 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/handler0', 'handler0');\n $r->addRoute('GET', '/handler1', 'handler1');\n $r->addRoute('GET', '/handler2', 'handler2');\n };\n\n $method = 'GET';\n $uri = '/handler2';\n $handler = 'handler2';\n $argDict = [];\n\n $cases[] = [$method, $uri, $callback, $handler, $argDict];\n\n // 2 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/user"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":482,"symbol":"provideNotFoundDispatchCases","kind":"method","lang":"php","code":"public static function provideNotFoundDispatchCases()\n {\n $cases = [];\n\n // 0 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/resource/123/456', 'handler0');\n };\n\n $method = 'GET';\n $uri = '/not-found';\n\n $cases[] = [$method, $uri, $callback];\n\n // 1 -------------------------------------------------------------------------------------->\n\n // reuse callback from #0\n $method = 'POST';\n $uri = '/not-found';\n\n $cases[] = [$method, $uri, $callback];\n\n // 2 -------------------------------------------------------------------------------------->\n\n // reuse callback from #1\n $method = 'PUT';\n $uri = '/not-found';\n\n $cases[] = [$method, $uri, $callback];\n\n // 3 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/handler0', 'handler0');\n $r->addRoute('GET', '/handler1', 'handler1');\n $r->addRoute('GET', '/ha"} {"repo":"slim","file":"tests/Routing/FastRouteDispatcherTest.php","line":559,"symbol":"provideMethodNotAllowedDispatchCases","kind":"method","lang":"php","code":"public static function provideMethodNotAllowedDispatchCases()\n {\n $cases = [];\n\n // 0 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/resource/123/456', 'handler0');\n };\n\n $method = 'POST';\n $uri = '/resource/123/456';\n $allowedMethods = ['GET'];\n\n $cases[] = [$method, $uri, $callback, $allowedMethods];\n\n // 1 -------------------------------------------------------------------------------------->\n\n $callback = function (RouteCollector $r) {\n $r->addRoute('GET', '/resource/123/456', 'handler0');\n $r->addRoute('POST', '/resource/123/456', 'handler1');\n $r->addRoute('PUT', '/resource/123/456', 'handler2');\n $r->addRoute('*', '/', 'handler3');\n };\n\n $method = 'DELETE';\n $uri = '/resource/123/456';\n $allowedMethods = ['GET', 'POST', 'PUT'];\n\n $cases[] = [$method, $uri, $callback, $allowedMethods];\n\n // 2 -------------------------------------------------------------------------------------->\n\n $callback = fu"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":26,"symbol":"RouteCollectorProxyTest","kind":"class","lang":"php","code":"class RouteCollectorProxyTest extends TestCase\n{\n public function testGetResponseFactory()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n\n $this->assertSame(\n $responseFactoryProphecy->reveal(),\n $routeCollectorProxy->getResponseFactory()\n );\n }\n\n public function testGetCallableResolver()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n\n $this->assertSame(\n $callableResolverProphecy->reveal(),\n $routeCollectorProxy->getCallableResolver()\n );\n }\n\n public function testGetContainerReturnsInjectedInstance()\n {\n"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":28,"symbol":"testGetResponseFactory","kind":"method","lang":"php","code":"public function testGetResponseFactory()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n\n $this->assertSame(\n $responseFactoryProphecy->reveal(),\n $routeCollectorProxy->getResponseFactory()\n );\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":44,"symbol":"testGetCallableResolver","kind":"method","lang":"php","code":"public function testGetCallableResolver()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n\n $this->assertSame(\n $callableResolverProphecy->reveal(),\n $routeCollectorProxy->getCallableResolver()\n );\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":60,"symbol":"testGetContainerReturnsInjectedInstance","kind":"method","lang":"php","code":"public function testGetContainerReturnsInjectedInstance()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $containerProphecy->reveal()\n );\n\n $this->assertSame(\n $containerProphecy->reveal(),\n $routeCollectorProxy->getContainer()\n );\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":78,"symbol":"testGetRouteCollectorReturnsInjectedInstance","kind":"method","lang":"php","code":"public function testGetRouteCollectorReturnsInjectedInstance()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $containerProphecy->reveal(),\n $routeCollectorProphecy->reveal()\n );\n\n $this->assertSame(\n $routeCollectorProphecy->reveal(),\n $routeCollectorProxy->getRouteCollector()\n );\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":98,"symbol":"testGetSetBasePath","kind":"method","lang":"php","code":"public function testGetSetBasePath()\n {\n $basePath = '/base/path';\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $containerProphecy->reveal()\n );\n\n $routeCollectorProxy->setBasePath($basePath);\n\n $this->assertSame($basePath, $routeCollectorProxy->getBasePath());\n\n $newBasePath = '/new/base/path';\n $routeCollectorProxy->setBasePath('/new/base/path');\n\n $this->assertSame($newBasePath, $routeCollectorProxy->getBasePath());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":122,"symbol":"testGet","kind":"method","lang":"php","code":"public function testGet()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['GET'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->get($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":155,"symbol":"testPost","kind":"method","lang":"php","code":"public function testPost()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['POST'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->post($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":188,"symbol":"testPut","kind":"method","lang":"php","code":"public function testPut()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['PUT'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->put($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":221,"symbol":"testPatch","kind":"method","lang":"php","code":"public function testPatch()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['PATCH'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->patch($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":254,"symbol":"testDelete","kind":"method","lang":"php","code":"public function testDelete()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['DELETE'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->delete($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":287,"symbol":"testOptions","kind":"method","lang":"php","code":"public function testOptions()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['OPTIONS'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->options($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":320,"symbol":"testAny","kind":"method","lang":"php","code":"public function testAny()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->any($pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":353,"symbol":"testMap","kind":"method","lang":"php","code":"public function testMap()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/';\n $methods = ['GET', 'POST'];\n $callable = function () {\n };\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn($pattern)\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->map($methods, $pattern, Argument::is($callable))\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $route = $routeCollectorProxy->map($methods, $pattern, $callable);\n\n $this->assertSame($pattern, $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":387,"symbol":"testRedirect","kind":"method","lang":"php","code":"public function testRedirect()\n {\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n\n $from = '/from';\n $to = '/to';\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $responseProphecy\n ->withHeader('Location', $to)\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->will(function () use ($responseProphecy) {\n $this\n ->createResponse(302)\n ->willReturn($responseProphecy)\n ->shouldBeCalledOnce();\n return $responseProphecy->reveal();\n })\n ->shouldBeCalledOnce();\n\n $routeCollector = new RouteCollector(\n $responseFactoryProphecy->reveal(),\n $callableResolver\n );\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $cal"} {"repo":"slim","file":"tests/Routing/RouteCollectorProxyTest.php","line":432,"symbol":"testGroup","kind":"method","lang":"php","code":"public function testGroup()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $pattern = '/group';\n $callable = function () {\n };\n\n $routeGroupProphecy = $this->prophesize(RouteGroupInterface::class);\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->group($pattern, Argument::is($callable))\n ->willReturn($routeGroupProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxy = new RouteCollectorProxy(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $routeCollectorProphecy->reveal()\n );\n\n $routeCollectorProxy->group($pattern, $callable);\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":29,"symbol":"RouteCollectorTest","kind":"class","lang":"php","code":"class RouteCollectorTest extends TestCase\n{\n /**\n * @var null|string\n */\n protected $cacheFile;\n\n public function tearDown(): void\n {\n if ($this->cacheFile && file_exists($this->cacheFile)) {\n unlink($this->cacheFile);\n }\n }\n\n public function testGetSetBasePath()\n {\n $basePath = '/app';\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->setBasePath($basePath);\n\n $this->assertSame($basePath, $routeCollector->getBasePath());\n }\n\n public function testMap()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $route = $routeCollector->map(['GET'], '/', function () {\n });\n\n $routes "} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":36,"symbol":"tearDown","kind":"method","lang":"php","code":"public function tearDown(): void\n {\n if ($this->cacheFile && file_exists($this->cacheFile)) {\n unlink($this->cacheFile);\n }\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":43,"symbol":"testGetSetBasePath","kind":"method","lang":"php","code":"public function testGetSetBasePath()\n {\n $basePath = '/app';\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->setBasePath($basePath);\n\n $this->assertSame($basePath, $routeCollector->getBasePath());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":56,"symbol":"testMap","kind":"method","lang":"php","code":"public function testMap()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $route = $routeCollector->map(['GET'], '/', function () {\n });\n\n $routes = $routeCollector->getRoutes();\n $this->assertSame($route, $routes[$route->getIdentifier()]);\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":69,"symbol":"testMapPrependsGroupPattern","kind":"method","lang":"php","code":"public function testMapPrependsGroupPattern()\n {\n $self = $this;\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n\n $callable = function (RouteCollectorProxy $proxy) use ($self) {\n $route = $proxy->get('/test', function () {\n });\n\n $self->assertSame('/prefix/test', $route->getPattern());\n };\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $callableResolverProphecy\n ->resolve(Argument::is($callable))\n ->willReturn($callable)\n ->shouldBeCalledOnce();\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->group('/prefix', $callable);\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":92,"symbol":"testGetRouteInvocationStrategy","kind":"method","lang":"php","code":"public function testGetRouteInvocationStrategy()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $invocationStrategyProphecy = $this->prophesize(InvocationStrategyInterface::class);\n\n $routeCollector = new RouteCollector(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $containerProphecy->reveal(),\n $invocationStrategyProphecy->reveal()\n );\n\n $this->assertSame($invocationStrategyProphecy->reveal(), $routeCollector->getDefaultInvocationStrategy());\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":109,"symbol":"testRemoveNamedRoute","kind":"method","lang":"php","code":"public function testRemoveNamedRoute()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->setBasePath('/base/path');\n\n $route = $routeCollector->map(['GET'], '/test', function () {\n });\n $route->setName('test');\n\n $routes = $routeCollector->getRoutes();\n $this->assertCount(1, $routes);\n\n $routeCollector->removeNamedRoute('test');\n $routes = $routeCollector->getRoutes();\n $this->assertCount(0, $routes);\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":129,"symbol":"testRemoveNamedRouteWithARouteThatDoesNotExist","kind":"method","lang":"php","code":"public function testRemoveNamedRouteWithARouteThatDoesNotExist()\n {\n $this->expectException(RuntimeException::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->removeNamedRoute('missing');\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":140,"symbol":"testLookupRouteThrowsExceptionIfRouteNotFound","kind":"method","lang":"php","code":"public function testLookupRouteThrowsExceptionIfRouteNotFound()\n {\n $this->expectException(RuntimeException::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->lookupRoute('missing');\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":154,"symbol":"testCacheFileExistsAndIsNotReadable","kind":"method","lang":"php","doc":"Test cache file exists but is not writable","code":"public function testCacheFileExistsAndIsNotReadable()\n {\n $this->cacheFile = __DIR__ . '/non-readable.cache';\n file_put_contents($this->cacheFile, '');\n\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage(sprintf('Route collector cache file `%s` is not readable', $this->cacheFile));\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->setCacheFile($this->cacheFile);\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":172,"symbol":"testCacheFileDoesNotExistsAndDirectoryIsNotWritable","kind":"method","lang":"php","doc":"Test cache file does not exist and directory is not writable","code":"public function testCacheFileDoesNotExistsAndDirectoryIsNotWritable()\n {\n $cacheFile = __DIR__ . '/non-writable-directory/router.cache';\n\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage(sprintf(\n 'Route collector cache file directory `%s` is not writable',\n dirname($cacheFile)\n ));\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->setCacheFile($cacheFile);\n }"} {"repo":"slim","file":"tests/Routing/RouteCollectorTest.php","line":189,"symbol":"testSetCacheFileViaConstructor","kind":"method","lang":"php","code":"public function testSetCacheFileViaConstructor()\n {\n $cacheFile = __DIR__ . '/router.cache';\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector(\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n null,\n null,\n $cacheFile\n );\n $this->assertSame($cacheFile, $routeCollector->getCacheFile());\n }"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":21,"symbol":"RouteContextTest","kind":"class","lang":"php","code":"class RouteContextTest extends TestCase\n{\n public function testCanCreateInstanceFromServerRequest(): void\n {\n $route = $this->createMock(RouteInterface::class);\n $routeParser = $this->createMock(RouteParserInterface::class);\n $routingResults = $this->createMock(RoutingResults::class);\n\n $serverRequest = $this->createServerRequest('/')\n ->withAttribute(RouteContext::BASE_PATH, '')\n ->withAttribute(RouteContext::ROUTE, $route)\n ->withAttribute(RouteContext::ROUTE_PARSER, $routeParser)\n ->withAttribute(RouteContext::ROUTING_RESULTS, $routingResults);\n\n $routeContext = RouteContext::fromRequest($serverRequest);\n\n $this->assertSame($route, $routeContext->getRoute());\n $this->assertSame($routeParser, $routeContext->getRouteParser());\n $this->assertSame($routingResults, $routeContext->getRoutingResults());\n $this->assertSame('', $routeContext->getBasePath());\n }\n\n public function testCanCreateInstanceWithoutRoute(): void\n {\n $serverRequest = $this->createServerRequestWithRouteAttributes();\n\n"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":23,"symbol":"testCanCreateInstanceFromServerRequest","kind":"method","lang":"php","code":"public function testCanCreateInstanceFromServerRequest(): void\n {\n $route = $this->createMock(RouteInterface::class);\n $routeParser = $this->createMock(RouteParserInterface::class);\n $routingResults = $this->createMock(RoutingResults::class);\n\n $serverRequest = $this->createServerRequest('/')\n ->withAttribute(RouteContext::BASE_PATH, '')\n ->withAttribute(RouteContext::ROUTE, $route)\n ->withAttribute(RouteContext::ROUTE_PARSER, $routeParser)\n ->withAttribute(RouteContext::ROUTING_RESULTS, $routingResults);\n\n $routeContext = RouteContext::fromRequest($serverRequest);\n\n $this->assertSame($route, $routeContext->getRoute());\n $this->assertSame($routeParser, $routeContext->getRouteParser());\n $this->assertSame($routingResults, $routeContext->getRoutingResults());\n $this->assertSame('', $routeContext->getBasePath());\n }"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":43,"symbol":"testCanCreateInstanceWithoutRoute","kind":"method","lang":"php","code":"public function testCanCreateInstanceWithoutRoute(): void\n {\n $serverRequest = $this->createServerRequestWithRouteAttributes();\n\n // Route attribute is not required\n $serverRequest = $serverRequest->withoutAttribute(RouteContext::ROUTE);\n\n $routeContext = RouteContext::fromRequest($serverRequest);\n $this->assertNull($routeContext->getRoute());\n $this->assertNotNull($routeContext->getRouteParser());\n $this->assertNotNull($routeContext->getRoutingResults());\n $this->assertNotNull($routeContext->getBasePath());\n }"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":57,"symbol":"testCanCreateInstanceWithoutBasePathAndThrowExceptionIfGetBasePathIsCalled","kind":"method","lang":"php","code":"public function testCanCreateInstanceWithoutBasePathAndThrowExceptionIfGetBasePathIsCalled(): void\n {\n $serverRequest = $this->createServerRequestWithRouteAttributes();\n\n // Route attribute is not required\n $serverRequest = $serverRequest->withoutAttribute(RouteContext::BASE_PATH);\n\n $routeContext = RouteContext::fromRequest($serverRequest);\n $this->assertNotNull($routeContext->getRoute());\n $this->assertNotNull($routeContext->getRouteParser());\n $this->assertNotNull($routeContext->getRoutingResults());\n\n $this->expectException(RuntimeException::class);\n $routeContext->getBasePath();\n }"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":73,"symbol":"requiredRouteContextRequestAttributes","kind":"method","lang":"php","code":"public static function requiredRouteContextRequestAttributes(): array\n {\n return [\n [RouteContext::ROUTE_PARSER],\n [RouteContext::ROUTING_RESULTS],\n ];\n }"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":85,"symbol":"testCannotCreateInstanceIfRequestIsMissingAttributes","kind":"method","lang":"php","doc":"@dataProvider requiredRouteContextRequestAttributes @param string $attribute","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('requiredRouteContextRequestAttributes')]\n public function testCannotCreateInstanceIfRequestIsMissingAttributes(string $attribute): void\n {\n $this->expectException(RuntimeException::class);\n\n $serverRequest = $this->createServerRequestWithRouteAttributes()->withoutAttribute($attribute);\n\n RouteContext::fromRequest($serverRequest);\n }"} {"repo":"slim","file":"tests/Routing/RouteContextTest.php","line":95,"symbol":"createServerRequestWithRouteAttributes","kind":"method","lang":"php","code":"private function createServerRequestWithRouteAttributes(): ServerRequestInterface\n {\n $route = $this->createMock(RouteInterface::class);\n $routeParser = $this->createMock(RouteParserInterface::class);\n $routingResults = $this->createMock(RoutingResults::class);\n\n return $this->createServerRequest('/')\n ->withAttribute(RouteContext::BASE_PATH, '')\n ->withAttribute(RouteContext::ROUTE, $route)\n ->withAttribute(RouteContext::ROUTE_PARSER, $routeParser)\n ->withAttribute(RouteContext::ROUTING_RESULTS, $routingResults);\n }"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":18,"symbol":"RouteParserTest","kind":"class","lang":"php","code":"class RouteParserTest extends TestCase\n{\n public static function urlForCases()\n {\n return [\n 'with base path' => [\n true,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n [],\n '/app/hello/world',\n ],\n 'without base path' => [\n false,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n [],\n '/hello/world',\n ],\n 'with query parameters' => [\n false,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n ['a' => 'b', 'c' => 'd'],\n '/hello/world?a=b&c=d',\n ],\n 'with query parameters containing array with string keys' => [\n false,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n ['a' => ['k' => '1', 'f' => 'x'], 'b', 'c' => 'd'],\n '/hello/world?a%5Bk%5D=1&a%5Bf%5D=x&0=b&c=d',\n ],\n 'with query parameters containing array w"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":20,"symbol":"urlForCases","kind":"method","lang":"php","code":"public static function urlForCases()\n {\n return [\n 'with base path' => [\n true,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n [],\n '/app/hello/world',\n ],\n 'without base path' => [\n false,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n [],\n '/hello/world',\n ],\n 'with query parameters' => [\n false,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n ['a' => 'b', 'c' => 'd'],\n '/hello/world?a=b&c=d',\n ],\n 'with query parameters containing array with string keys' => [\n false,\n '/{first}/{second}',\n ['first' => 'hello', 'second' => 'world'],\n ['a' => ['k' => '1', 'f' => 'x'], 'b', 'c' => 'd'],\n '/hello/world?a%5Bk%5D=1&a%5Bf%5D=x&0=b&c=d',\n ],\n 'with query parameters containing array with numeric keys' => [\n false,"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":82,"symbol":"testRelativePathForWithNoBasePath","kind":"method","lang":"php","code":"public function testRelativePathForWithNoBasePath()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n\n $route = $routeCollector->map(['GET'], '/{first}/{second}', function () {\n });\n $route->setName('test');\n\n $routeParser = $routeCollector->getRouteParser();\n $results = $routeParser->relativeUrlFor('test', ['first' => 'hello', 'second' => 'world']);\n\n $this->assertSame('/hello/world', $results);\n }"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":99,"symbol":"testBasePathIsIgnoreInRelativePathFor","kind":"method","lang":"php","code":"public function testBasePathIsIgnoreInRelativePathFor()\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeCollector->setBasePath('/app');\n\n $route = $routeCollector->map(['GET'], '/{first}/{second}', function () {\n });\n $route->setName('test');\n\n $routeParser = $routeCollector->getRouteParser();\n $results = $routeParser->relativeUrlFor('test', ['first' => 'hello', 'second' => 'world']);\n\n $this->assertSame('/hello/world', $results);\n }"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":125,"symbol":"testUrlForWithBasePath","kind":"method","lang":"php","doc":"@param $withBasePath @param $pattern @param $arguments @param $queryParams @param $expectedResult","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('urlForCases')]\n public function testUrlForWithBasePath($withBasePath, $pattern, $arguments, $queryParams, $expectedResult)\n {\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n\n if ($withBasePath) {\n $routeCollector->setBasePath('/app');\n }\n\n $route = $routeCollector->map(['GET'], $pattern, function () {\n });\n $route->setName('test');\n\n $routeParser = $routeCollector->getRouteParser();\n $results = $routeParser->urlFor('test', $arguments, $queryParams);\n\n $this->assertSame($expectedResult, $results);\n }"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":147,"symbol":"testUrlForWithMissingSegmentData","kind":"method","lang":"php","code":"public function testUrlForWithMissingSegmentData()\n {\n $this->expectException(InvalidArgumentException::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $route = $routeCollector->map(['GET'], '/{first}/{last}', function () {\n });\n $route->setName('test');\n\n $routeParser = $routeCollector->getRouteParser();\n $routeParser->urlFor('test', ['last' => 'world']);\n }"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":163,"symbol":"testUrlForRouteThatDoesNotExist","kind":"method","lang":"php","code":"public function testUrlForRouteThatDoesNotExist()\n {\n $this->expectException(RuntimeException::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());\n $routeParser = $routeCollector->getRouteParser();\n\n $routeParser->urlFor('test');\n }"} {"repo":"slim","file":"tests/Routing/RouteParserTest.php","line":176,"symbol":"testFullUrlFor","kind":"method","lang":"php","code":"public function testFullUrlFor()\n {\n $uriProphecy = $this->prophesize(UriInterface::class);\n $uriProphecy\n ->getScheme()\n ->willReturn('http')\n ->shouldBeCalledOnce();\n\n $uriProphecy\n ->getAuthority()\n ->willReturn('example.com:8080')\n ->shouldBeCalledOnce();\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $routeProphecy\n ->getPattern()\n ->willReturn('/{token}')\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n\n $routeCollectorProphecy\n ->getBasePath()\n ->willReturn('/app')\n ->shouldBeCalledOnce();\n\n $routeCollectorProphecy\n ->getNamedRoute('test')\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeParser = new RouteParser($routeCollectorProphecy->reveal());\n $result = $routeParser->fullUrlFor($uriProphecy->reveal(), 'test', ['token' => '123']);\n\n $expectedResult = 'http://example.com:8080/app/123';\n $this->assertSame($expectedResult, $result);\n"} {"repo":"slim","file":"tests/Routing/RouteResolverTest.php","line":24,"symbol":"RouteResolverTest","kind":"class","lang":"php","code":"class RouteResolverTest extends TestCase\n{\n public static function computeRoutingResultsDataProvider(): array\n {\n return [\n ['GET', '', '/'],\n ['GET', '/', '/'],\n ['GET', '//foo', '//foo'],\n ['GET', 'hello%20world', '/hello world'],\n ];\n }\n\n /**\n * @dataProvider computeRoutingResultsDataProvider\n *\n * @param string $method The request method\n * @param string $uri The request uri\n * @param string $expectedUri The expected uri after transformation in the computeRoutingResults()\n */\n #[\\PHPUnit\\Framework\\Attributes\\DataProvider('computeRoutingResultsDataProvider')]\n public function testComputeRoutingResults(string $method, string $uri, string $expectedUri)\n {\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routingResultsProphecy = $this->prophesize(RoutingResults::class);\n\n $dispatcherProphecy = $this->prophesize(DispatcherInterface::class);\n $dispatcherProphecy\n ->dispatch(Argument::type('string'), Argument::type('string'))\n ->will(function ($args) use ($routingResultsProphecy, $expectedUr"} {"repo":"slim","file":"tests/Routing/RouteResolverTest.php","line":26,"symbol":"computeRoutingResultsDataProvider","kind":"method","lang":"php","code":"public static function computeRoutingResultsDataProvider(): array\n {\n return [\n ['GET', '', '/'],\n ['GET', '/', '/'],\n ['GET', '//foo', '//foo'],\n ['GET', 'hello%20world', '/hello world'],\n ];\n }"} {"repo":"slim","file":"tests/Routing/RouteResolverTest.php","line":43,"symbol":"testComputeRoutingResults","kind":"method","lang":"php","doc":"@dataProvider computeRoutingResultsDataProvider @param string $method The request method @param string $uri The request uri @param string $expectedUri The expected uri after transformation in the computeRoutingResults()","code":"#[\\PHPUnit\\Framework\\Attributes\\DataProvider('computeRoutingResultsDataProvider')]\n public function testComputeRoutingResults(string $method, string $uri, string $expectedUri)\n {\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routingResultsProphecy = $this->prophesize(RoutingResults::class);\n\n $dispatcherProphecy = $this->prophesize(DispatcherInterface::class);\n $dispatcherProphecy\n ->dispatch(Argument::type('string'), Argument::type('string'))\n ->will(function ($args) use ($routingResultsProphecy, $expectedUri) {\n if ($args[1] !== $expectedUri) {\n throw new Error(sprintf(\n \"URI transformation failed.\\n Received: '%s'\\n Expected: '%s'\",\n $args[1],\n $expectedUri\n ));\n }\n return $routingResultsProphecy->reveal();\n })\n ->shouldBeCalledOnce();\n\n $routeResolver = new RouteResolver(\n $routeCollectorProphecy->reveal(),\n $dispatcherProphecy->reveal()\n );\n\n $routeResolver->computeRoutingR"} {"repo":"slim","file":"tests/Routing/RouteResolverTest.php","line":72,"symbol":"testResolveRoute","kind":"method","lang":"php","code":"public function testResolveRoute()\n {\n $identifier = 'test';\n\n $routeProphecy = $this->prophesize(RouteInterface::class);\n $dispatcherProphecy = $this->prophesize(DispatcherInterface::class);\n\n $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);\n $routeCollectorProphecy\n ->lookupRoute($identifier)\n ->willReturn($routeProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeResolver = new RouteResolver(\n $routeCollectorProphecy->reveal(),\n $dispatcherProphecy->reveal()\n );\n\n $routeResolver->resolveRoute($identifier);\n }"} {"repo":"slim","file":"tests/Routing/RouteRunnerTest.php","line":24,"symbol":"RouteRunnerTest","kind":"class","lang":"php","code":"class RouteRunnerTest extends TestCase\n{\n public function testRoutingIsPerformedIfRoutingResultsAreUnavailable()\n {\n $handler = (function (ServerRequestInterface $request, ResponseInterface $response) {\n $routeParser = $request->getAttribute(RouteContext::ROUTE_PARSER);\n $this->assertInstanceOf(RouteParser::class, $routeParser);\n\n $routingResults = $request->getAttribute(RouteContext::ROUTING_RESULTS);\n $this->assertInstanceOf(RoutingResults::class, $routingResults);\n\n return $response;\n })->bindTo($this);\n\n $callableResolver = $this->getCallableResolver();\n $responseFactory = $this->getResponseFactory();\n\n $routeCollector = new RouteCollector($responseFactory, $callableResolver);\n $routeCollector->map(['GET'], '/hello/{name}', $handler);\n\n $routeParser = new RouteParser($routeCollector);\n $routeResolver = new RouteResolver($routeCollector);\n\n $request = $this->createServerRequest('https://example.com:443/hello/foo', 'GET');\n $dispatcher = new RouteRunner($routeResolver, $routeParser);\n\n $middlewareDispatcher = new MiddlewareDispatcher($dispatche"} {"repo":"slim","file":"tests/Routing/RouteRunnerTest.php","line":26,"symbol":"testRoutingIsPerformedIfRoutingResultsAreUnavailable","kind":"method","lang":"php","code":"public function testRoutingIsPerformedIfRoutingResultsAreUnavailable()\n {\n $handler = (function (ServerRequestInterface $request, ResponseInterface $response) {\n $routeParser = $request->getAttribute(RouteContext::ROUTE_PARSER);\n $this->assertInstanceOf(RouteParser::class, $routeParser);\n\n $routingResults = $request->getAttribute(RouteContext::ROUTING_RESULTS);\n $this->assertInstanceOf(RoutingResults::class, $routingResults);\n\n return $response;\n })->bindTo($this);\n\n $callableResolver = $this->getCallableResolver();\n $responseFactory = $this->getResponseFactory();\n\n $routeCollector = new RouteCollector($responseFactory, $callableResolver);\n $routeCollector->map(['GET'], '/hello/{name}', $handler);\n\n $routeParser = new RouteParser($routeCollector);\n $routeResolver = new RouteResolver($routeCollector);\n\n $request = $this->createServerRequest('https://example.com:443/hello/foo', 'GET');\n $dispatcher = new RouteRunner($routeResolver, $routeParser);\n\n $middlewareDispatcher = new MiddlewareDispatcher($dispatcher, $callableResolver);\n $middlewareDis"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":43,"symbol":"RouteTest","kind":"class","lang":"php","code":"class RouteTest extends TestCase\n{\n /**\n * @param string|array $methods\n * @param string $pattern\n * @param Closure|string|null $callable\n * @return Route\n */\n public function createRoute($methods = 'GET', string $pattern = '/', $callable = null): Route\n {\n $callable ??= function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $callableResolverProphecy\n ->resolve(Argument::is($callable))\n ->willReturn($callable);\n $callableResolverProphecy\n ->resolve(MockMiddlewareWithoutConstructor::class)\n ->will(function ($args) {\n return [new MockMiddlewareWithoutConstructor(), 'process'];\n });\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n\n $value = '';\n $streamProphecy\n ->write(Argument::type('string'))\n ->will(function ($args) use ($value) {\n $value .= $args[0];\n $this->__toString()->willReturn($value);\n "} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":51,"symbol":"createRoute","kind":"method","lang":"php","doc":"@param string|array $methods @param string $pattern @param Closure|string|null $callable @return Route","code":"public function createRoute($methods = 'GET', string $pattern = '/', $callable = null): Route\n {\n $callable ??= function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $callableResolverProphecy\n ->resolve(Argument::is($callable))\n ->willReturn($callable);\n $callableResolverProphecy\n ->resolve(MockMiddlewareWithoutConstructor::class)\n ->will(function ($args) {\n return [new MockMiddlewareWithoutConstructor(), 'process'];\n });\n\n $streamProphecy = $this->prophesize(StreamInterface::class);\n\n $value = '';\n $streamProphecy\n ->write(Argument::type('string'))\n ->will(function ($args) use ($value) {\n $value .= $args[0];\n $this->__toString()->willReturn($value);\n return strlen($value);\n });\n\n $streamProphecy\n ->__toString()\n ->willReturn($value);\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n "} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":110,"symbol":"testConstructor","kind":"method","lang":"php","code":"public function testConstructor()\n {\n $methods = ['GET', 'POST'];\n $pattern = '/hello/{name}';\n $callable = function ($request, $response, $args) {\n return $response;\n };\n $route = $this->createRoute($methods, $pattern, $callable);\n\n $this->assertSame($methods, $route->getMethods());\n $this->assertSame($pattern, $route->getPattern());\n $this->assertSame($callable, $route->getCallable());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":124,"symbol":"testGetMethodsReturnsArrayWhenConstructedWithString","kind":"method","lang":"php","code":"public function testGetMethodsReturnsArrayWhenConstructedWithString()\n {\n $route = $this->createRoute();\n\n $this->assertSame(['GET'], $route->getMethods());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":131,"symbol":"testGetMethods","kind":"method","lang":"php","code":"public function testGetMethods()\n {\n $methods = ['GET', 'POST'];\n $route = $this->createRoute($methods);\n\n $this->assertSame($methods, $route->getMethods());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":139,"symbol":"testGetPattern","kind":"method","lang":"php","code":"public function testGetPattern()\n {\n $route = $this->createRoute();\n\n $this->assertSame('/', $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":146,"symbol":"testGetCallable","kind":"method","lang":"php","code":"public function testGetCallable()\n {\n $route = $this->createRoute();\n\n $this->assertTrue(is_callable($route->getCallable()));\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":153,"symbol":"testGetCallableResolver","kind":"method","lang":"php","code":"public function testGetCallableResolver()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $route = new Route(\n ['GET'],\n '/',\n $callable,\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n\n $this->assertSame($callableResolverProphecy->reveal(), $route->getCallableResolver());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":173,"symbol":"testGetInvocationStrategy","kind":"method","lang":"php","code":"public function testGetInvocationStrategy()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $strategyProphecy = $this->prophesize(InvocationStrategyInterface::class);\n\n $route = new Route(\n ['GET'],\n '/',\n $callable,\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n $containerProphecy->reveal(),\n $strategyProphecy->reveal()\n );\n\n $this->assertSame($strategyProphecy->reveal(), $route->getInvocationStrategy());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":197,"symbol":"testSetInvocationStrategy","kind":"method","lang":"php","code":"public function testSetInvocationStrategy()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $strategyProphecy = $this->prophesize(InvocationStrategyInterface::class);\n\n $route = new Route(\n ['GET'],\n '/',\n $callable,\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal()\n );\n $route->setInvocationStrategy($strategyProphecy->reveal());\n\n $this->assertSame($strategyProphecy->reveal(), $route->getInvocationStrategy());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":219,"symbol":"testGetGroups","kind":"method","lang":"php","code":"public function testGetGroups()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $strategyProphecy = $this->prophesize(InvocationStrategyInterface::class);\n $routeCollectorProxyProphecy = $this->prophesize(RouteCollectorProxyInterface::class);\n\n $routeGroup = new RouteGroup(\n '/group',\n $callable,\n $callableResolverProphecy->reveal(),\n $routeCollectorProxyProphecy->reveal()\n );\n $groups = [$routeGroup];\n\n $route = new Route(\n ['GET'],\n '/',\n $callable,\n $responseFactoryProphecy->reveal(),\n $callableResolverProphecy->reveal(),\n null,\n $strategyProphecy->reveal(),\n $groups\n );\n\n $this->assertSame($groups, $route->getGroups());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":252,"symbol":"testArgumentSetting","kind":"method","lang":"php","code":"public function testArgumentSetting()\n {\n $route = $this->createRoute();\n $route->setArguments(['foo' => 'FOO', 'bar' => 'BAR']);\n $this->assertSame($route->getArguments(), ['foo' => 'FOO', 'bar' => 'BAR']);\n\n $route->setArgument('bar', 'bar');\n $this->assertSame($route->getArguments(), ['foo' => 'FOO', 'bar' => 'bar']);\n\n $route->setArgument('baz', 'BAZ');\n $this->assertSame($route->getArguments(), ['foo' => 'FOO', 'bar' => 'bar', 'baz' => 'BAZ']);\n\n $route->setArguments(['a' => 'b']);\n $this->assertSame($route->getArguments(), ['a' => 'b']);\n $this->assertSame($route->getArgument('a', 'default'), 'b');\n $this->assertSame($route->getArgument('b', 'default'), 'default');\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":270,"symbol":"testAddMiddleware","kind":"method","lang":"php","code":"public function testAddMiddleware()\n {\n $route = $this->createRoute();\n $called = 0;\n\n $mw = function (ServerRequestInterface $request, RequestHandlerInterface $handler) use (&$called) {\n $called++;\n return $handler->handle($request);\n };\n $route->add($mw);\n\n $request = $this->createServerRequest('/');\n $route->run($request);\n\n $this->assertSame($called, 1);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":287,"symbol":"testAddMiddlewareOnGroup","kind":"method","lang":"php","code":"public function testAddMiddlewareOnGroup()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n return $response;\n };\n\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n $callableResolverProphecy\n ->resolve(Argument::is($callable))\n ->willReturn($callable)\n ->shouldBeCalledOnce();\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $routeCollectorProxyProphecy = $this->prophesize(RouteCollectorProxyInterface::class);\n $strategy = new RequestResponse();\n\n $called = 0;\n $mw = function (ServerRequestInterface $request, RequestHandlerInterface $handler) use (&$called) {\n $called++;\n return $handler->handle($request);\n };\n\n $routeGroup = new RouteGroup(\n '/group',\n $callable,\n $callableRe"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":342,"symbol":"testAddClosureMiddleware","kind":"method","lang":"php","code":"public function testAddClosureMiddleware()\n {\n $route = $this->createRoute();\n $called = 0;\n\n $route->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler) use (&$called) {\n $called++;\n return $handler->handle($request);\n });\n\n $request = $this->createServerRequest('/');\n $route->run($request);\n\n $this->assertSame($called, 1);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":358,"symbol":"testAddMiddlewareUsingDeferredResolution","kind":"method","lang":"php","code":"public function testAddMiddlewareUsingDeferredResolution()\n {\n $route = $this->createRoute();\n $route->add(MockMiddlewareWithoutConstructor::class);\n\n $output = '';\n $appendToOutput = function (string $value) use (&$output) {\n $output .= $value;\n };\n $request = $this->createServerRequest('/')->withAttribute('appendToOutput', $appendToOutput);\n $route->run($request);\n\n $this->assertSame('Hello World', $output);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":373,"symbol":"testAddMiddlewareAsStringNotImplementingInterfaceThrowsException","kind":"method","lang":"php","code":"public function testAddMiddlewareAsStringNotImplementingInterfaceThrowsException()\n {\n $this->expectException(RuntimeException::class);\n $this->expectExceptionMessage(\n 'A middleware must be an object/class name referencing an implementation of ' .\n 'MiddlewareInterface or a callable with a matching signature.'\n );\n\n $route = $this->createRoute();\n $route->add(new MockMiddlewareWithoutInterface());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":385,"symbol":"testIdentifier","kind":"method","lang":"php","code":"public function testIdentifier()\n {\n $route = $this->createRoute();\n $this->assertSame('route0', $route->getIdentifier());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":391,"symbol":"testSetName","kind":"method","lang":"php","code":"public function testSetName()\n {\n $route = $this->createRoute();\n $this->assertSame($route, $route->setName('foo'));\n $this->assertSame('foo', $route->getName());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":398,"symbol":"testControllerMethodAsStringResolvesWithoutContainer","kind":"method","lang":"php","code":"public function testControllerMethodAsStringResolvesWithoutContainer()\n {\n $callableResolver = new CallableResolver();\n $responseFactory = $this->getResponseFactory();\n\n $deferred = $callableResolver->resolve('\\Slim\\Tests\\Mocks\\CallableTest:toCall');\n $route = new Route(['GET'], '/', $deferred, $responseFactory, $callableResolver);\n\n CallableTest::$CalledCount = 0;\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $this->assertInstanceOf(ResponseInterface::class, $response);\n $this->assertSame(1, CallableTest::$CalledCount);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":415,"symbol":"testControllerMethodAsStringResolvesWithContainer","kind":"method","lang":"php","code":"public function testControllerMethodAsStringResolvesWithContainer()\n {\n $self = $this;\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n $callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);\n\n $callable = 'callable';\n\n $callableResolverProphecy\n ->resolve(Argument::is($callable))\n ->willReturn(function (\n ServerRequestInterface $request,\n ResponseInterface $response\n ) use (\n $self,\n $responseProphecy\n ) {\n $self->assertSame($responseProphecy->reveal(), $response);\n return $response;\n })\n ->shouldBeCalledOnce();\n\n $deferred = $callableResolverProphecy->reveal()->resolve($callable);\n $callableResolverProphecy\n ->resolve(Argument::is($deferred))\n ->willReturn($deferred)\n ->shouldBeCalledOnce();\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal());\n\n "} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":467,"symbol":"testProcessWhenReturningAResponse","kind":"method","lang":"php","doc":"Ensure that the response returned by a route callable is the response object that is returned by __invoke().","code":"public function testProcessWhenReturningAResponse()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n $response->getBody()->write('foo');\n return $response;\n };\n $route = $this->createRoute(['GET'], '/', $callable);\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $this->assertSame('foo', (string) $response->getBody());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":485,"symbol":"testRouteCallableDoesNotAppendEchoedOutput","kind":"method","lang":"php","doc":"Ensure that anything echo'd in a route callable is, by default, NOT added to the response object body.","code":"public function testRouteCallableDoesNotAppendEchoedOutput()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n echo \"foo\";\n return $response->withStatus(201);\n };\n $route = $this->createRoute(['GET'], '/', $callable);\n\n $request = $this->createServerRequest('/');\n\n // We capture output buffer here only to clean test CLI output\n ob_start();\n $response = $route->run($request);\n ob_end_clean();\n\n // Output buffer is ignored without optional middleware\n $this->assertSame('', (string) $response->getBody());\n $this->assertSame(201, $response->getStatusCode());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":509,"symbol":"testRouteCallableAppendsCorrectOutputToResponse","kind":"method","lang":"php","doc":"Ensure that if a string is returned by a route callable, then it is added to the response object that is returned by __invoke().","code":"public function testRouteCallableAppendsCorrectOutputToResponse()\n {\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n $response->getBody()->write('foo');\n return $response;\n };\n $route = $this->createRoute(['GET'], '/', $callable);\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $this->assertSame('foo', (string) $response->getBody());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":523,"symbol":"testInvokeWithException","kind":"method","lang":"php","code":"public function testInvokeWithException()\n {\n $this->expectException(Exception::class);\n\n $callable = function (ServerRequestInterface $request, ResponseInterface $response) {\n throw new Exception();\n };\n $route = $this->createRoute(['GET'], '/', $callable);\n\n $request = $this->createServerRequest('/');\n $route->run($request);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":539,"symbol":"testInvokeDeferredCallableWithNoContainer","kind":"method","lang":"php","doc":"Ensure that `foundHandler` is called on actual callable","code":"public function testInvokeDeferredCallableWithNoContainer()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $callableResolver = new CallableResolver();\n $invocationStrategy = new InvocationStrategyTest();\n\n $deferred = '\\Slim\\Tests\\Mocks\\CallableTest:toCall';\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n null,\n $invocationStrategy\n );\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $this->assertInstanceOf(ResponseInterface::class, $response);\n $this->assertEquals([new CallableTest(), 'toCall'], InvocationStrategyTest::$LastCalledFor);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":573,"symbol":"testInvokeDeferredCallableWithContainer","kind":"method","lang":"php","doc":"Ensure that `foundHandler` is called on actual callable","code":"public function testInvokeDeferredCallableWithContainer()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('\\Slim\\Tests\\Mocks\\CallableTest')->willReturn(true);\n $containerProphecy->get('\\Slim\\Tests\\Mocks\\CallableTest')->willReturn(new CallableTest());\n\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n $strategy = new InvocationStrategyTest();\n\n $deferred = '\\Slim\\Tests\\Mocks\\CallableTest:toCall';\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n $containerProphecy->reveal(),\n $strategy\n );\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $this->assertInstanc"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":608,"symbol":"testInvokeUsesRequestHandlerStrategyForRequestHandlers","kind":"method","lang":"php","code":"public function testInvokeUsesRequestHandlerStrategyForRequestHandlers()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has(RequestHandlerTest::class)->willReturn(true);\n $containerProphecy->get(RequestHandlerTest::class)->willReturn(new RequestHandlerTest());\n\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n\n $deferred = RequestHandlerTest::class;\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n $containerProphecy->reveal()\n );\n\n $request = $this->createServerRequest('/', 'GET');\n $route->run($request);\n\n /** @var InvocationStrategyInterface $strategy */\n $strategy = $containerProphecy\n ->re"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":645,"symbol":"testInvokeUsesUserSetStrategyForRequestHandlers","kind":"method","lang":"php","code":"public function testInvokeUsesUserSetStrategyForRequestHandlers()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has(RequestHandlerTest::class)->willReturn(true);\n $containerProphecy->get(RequestHandlerTest::class)->willReturn(new RequestHandlerTest());\n\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n\n $deferred = RequestHandlerTest::class;\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n $containerProphecy->reveal()\n );\n\n $strategy = new MockCustomRequestHandlerInvocationStrategy();\n $route->setInvocationStrategy($strategy);\n\n $request = $this->createServerRequest('/', 'GET');\n $route->run($request);\n"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":680,"symbol":"testRequestHandlerStrategyAppendsRouteArgumentsAsAttributesToRequest","kind":"method","lang":"php","code":"public function testRequestHandlerStrategyAppendsRouteArgumentsAsAttributesToRequest()\n {\n $self = $this;\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has(RequestHandlerTest::class)->willReturn(true);\n $containerProphecy->get(RequestHandlerTest::class)->willReturn(new RequestHandlerTest());\n\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n\n $deferred = RequestHandlerTest::class;\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n $containerProphecy->reveal()\n );\n\n $strategy = new RequestHandler(true);\n $route->setInvocationStrategy($strategy);\n $route->setArguments(['id' => 1]);\n\n $requestProphecy ="} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":729,"symbol":"testPatternCanBeChanged","kind":"method","lang":"php","doc":"Ensure that the pattern can be dynamically changed","code":"public function testPatternCanBeChanged()\n {\n $route = $this->createRoute();\n $route->setPattern('/hola/{nombre}');\n\n $this->assertSame('/hola/{nombre}', $route->getPattern());\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":740,"symbol":"testChangingCallableWithNoContainer","kind":"method","lang":"php","doc":"Ensure that the callable can be changed","code":"public function testChangingCallableWithNoContainer()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $callableResolver = new CallableResolver();\n $strategy = new InvocationStrategyTest();\n\n $deferred = 'NonExistent:toCall';\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n null,\n $strategy\n );\n $route->setCallable('\\Slim\\Tests\\Mocks\\CallableTest:toCall'); //Then we fix it here.\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $this->assertInstanceOf(ResponseInterface::class, $response);\n $this->assertEquals([new CallableTest(), 'toCall'], InvocationStrategyTest::$LastCalledFor);\n }"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":775,"symbol":"testChangingCallableWithContainer","kind":"method","lang":"php","doc":"Ensure that the callable can be changed","code":"public function testChangingCallableWithContainer()\n {\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('CallableTest2')->willReturn(true);\n $containerProphecy->get('CallableTest2')->willReturn(new CallableTest());\n\n $callableResolver = new CallableResolver($containerProphecy->reveal());\n $strategy = new InvocationStrategyTest();\n\n $deferred = 'NonExistent:toCall';\n $route = new Route(\n ['GET'],\n '/',\n $deferred,\n $responseFactoryProphecy->reveal(),\n $callableResolver,\n $containerProphecy->reveal(),\n $strategy\n );\n $route->setCallable('CallableTest2:toCall'); //Then we fix it here.\n\n $request = $this->createServerRequest('/');\n $response = $route->run($request);\n\n $th"} {"repo":"slim","file":"tests/Routing/RouteTest.php","line":814,"symbol":"testRouteCallableIsResolvedUsingContainerWhenCallableResolverIsPresent","kind":"method","lang":"php","code":"public function testRouteCallableIsResolvedUsingContainerWhenCallableResolverIsPresent()\n {\n $streamProphecy = $this->prophesize(StreamInterface::class);\n\n $value = '';\n $streamProphecy\n ->write(Argument::type('string'))\n ->will(function ($args) use ($value) {\n $value .= $args[0];\n $this->__toString()->willReturn($value);\n return strlen($value);\n });\n\n $streamProphecy\n ->__toString()\n ->willReturn($value);\n\n $responseProphecy = $this->prophesize(ResponseInterface::class);\n\n $responseProphecy\n ->getBody()\n ->willReturn($streamProphecy->reveal())\n ->shouldBeCalledTimes(2);\n\n $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);\n $responseFactoryProphecy\n ->createResponse()\n ->willReturn($responseProphecy->reveal())\n ->shouldBeCalledOnce();\n\n $containerProphecy = $this->prophesize(ContainerInterface::class);\n $containerProphecy->has('CallableTest3')->willReturn(true);\n $containerProphecy->get('CallableTest3')->willRetu"} {"repo":"slim","file":"tests/TestCase.php","line":30,"symbol":"TestCase","kind":"class","lang":"php","code":"abstract class TestCase extends PhpUnitTestCase\n{\n use ProphecyTrait;\n\n /**\n * @return ServerRequestFactoryInterface\n */\n protected function getServerRequestFactory(): ServerRequestFactoryInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->getServerRequestFactory();\n }\n\n /**\n * @return ResponseFactoryInterface\n */\n protected function getResponseFactory(): ResponseFactoryInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->getResponseFactory();\n }\n\n /**\n * @return StreamFactoryInterface\n */\n protected function getStreamFactory(): StreamFactoryInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->getStreamFactory();\n }\n\n /**\n * @param ContainerInterface|null $container\n *\n * @return CallableResolverInterface\n */\n protected function getCallableResolver(?ContainerInterface $container = null): CallableResolverInterface\n {\n return new CallableResolver($container);\n }\n\n /**\n * @param RequestHandlerInterface $requestHandler\n * @p"} {"repo":"slim","file":"tests/TestCase.php","line":37,"symbol":"getServerRequestFactory","kind":"method","lang":"php","doc":"@return ServerRequestFactoryInterface","code":"protected function getServerRequestFactory(): ServerRequestFactoryInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->getServerRequestFactory();\n }"} {"repo":"slim","file":"tests/TestCase.php","line":46,"symbol":"getResponseFactory","kind":"method","lang":"php","doc":"@return ResponseFactoryInterface","code":"protected function getResponseFactory(): ResponseFactoryInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->getResponseFactory();\n }"} {"repo":"slim","file":"tests/TestCase.php","line":55,"symbol":"getStreamFactory","kind":"method","lang":"php","doc":"@return StreamFactoryInterface","code":"protected function getStreamFactory(): StreamFactoryInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->getStreamFactory();\n }"} {"repo":"slim","file":"tests/TestCase.php","line":66,"symbol":"getCallableResolver","kind":"method","lang":"php","doc":"@param ContainerInterface|null $container @return CallableResolverInterface","code":"protected function getCallableResolver(?ContainerInterface $container = null): CallableResolverInterface\n {\n return new CallableResolver($container);\n }"} {"repo":"slim","file":"tests/TestCase.php","line":78,"symbol":"createMiddlewareDispatcher","kind":"method","lang":"php","doc":"@param RequestHandlerInterface $requestHandler @param ContainerInterface|null $container @param CallableResolverInterface|null $callableResolver @return MiddlewareDispatcher","code":"protected function createMiddlewareDispatcher(\n RequestHandlerInterface $requestHandler,\n ?ContainerInterface $container = null,\n ?CallableResolverInterface $callableResolver = null\n ): MiddlewareDispatcher {\n return new MiddlewareDispatcher(\n $requestHandler,\n $callableResolver ?? $this->getCallableResolver($container),\n $container\n );\n }"} {"repo":"slim","file":"tests/TestCase.php","line":96,"symbol":"createServerRequest","kind":"method","lang":"php","doc":"@param string $uri @param string $method @param array $data @return ServerRequestInterface","code":"protected function createServerRequest(\n string $uri,\n string $method = 'GET',\n array $data = []\n ): ServerRequestInterface {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->createServerRequest($uri, $method, $data);\n }"} {"repo":"slim","file":"tests/TestCase.php","line":110,"symbol":"createResponse","kind":"method","lang":"php","doc":"@param int $statusCode @param string $reasonPhrase @return ResponseInterface","code":"protected function createResponse(int $statusCode = 200, string $reasonPhrase = ''): ResponseInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->createResponse($statusCode, $reasonPhrase);\n }"} {"repo":"slim","file":"tests/TestCase.php","line":120,"symbol":"createStream","kind":"method","lang":"php","doc":"@param string $contents @return StreamInterface","code":"protected function createStream(string $contents = ''): StreamInterface\n {\n $psr7ObjectProvider = new PSR7ObjectProvider();\n return $psr7ObjectProvider->createStream($contents);\n }"} {"repo":"slim","file":"tests/TestCase.php","line":130,"symbol":"setAccessible","kind":"method","lang":"php","doc":"@param ReflectionProperty|ReflectionMethod $ref @return void","code":"protected function setAccessible($ref, bool $accessible = true): void\n {\n if (PHP_VERSION_ID < 80100) {\n $ref->setAccessible($accessible);\n }\n }"}