diff --git a/src/Http/HttpIntegration.php b/src/Http/HttpIntegration.php index 9e9ab1e3..90b79a04 100644 --- a/src/Http/HttpIntegration.php +++ b/src/Http/HttpIntegration.php @@ -9,6 +9,7 @@ use Rougin\Slytherin\Http\ServerRequest; use Rougin\Slytherin\Integration\Configuration; use Rougin\Slytherin\Integration\IntegrationInterface; +use Rougin\Slytherin\System; use Zend\Diactoros\Response as ZendResponse; use Zend\Diactoros\ServerRequestFactory; @@ -124,26 +125,26 @@ protected function headers(array $server) */ protected function resolve(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response) { - $empty = $this->preferred === null; + $class = 'Zend\Diactoros\ServerRequestFactory'; - $hasDiactoros = class_exists('Zend\Diactoros\ServerRequestFactory'); + $empty = $this->preferred === null; - $wantDiactoros = $this->preferred === 'diactoros'; + $wantZend = $this->preferred === 'diactoros'; - if (($empty || $wantDiactoros) && $hasDiactoros) + if (($empty || $wantZend) && class_exists($class)) { $response = new ZendResponse; $request = ServerRequestFactory::fromGlobals(); } - $container->set('Psr\Http\Message\ServerRequestInterface', $request); + $container->set(System::REQUEST, $request); - return $container->set('Psr\Http\Message\ResponseInterface', $response); + return $container->set(System::RESPONSE, $response); } /** - * Returns a sample $_SERVER values. + * Returns a sample of $_SERVER values. * * @return array */ diff --git a/src/Http/LICENSE.md b/src/Http/LICENSE.md index 6811efc9..5a9df18e 100644 --- a/src/Http/LICENSE.md +++ b/src/Http/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2004-2018 Fabien Potencier +Copyright (c) 2004-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Integration/Configuration.php b/src/Integration/Configuration.php index dd08baac..ddf5802f 100644 --- a/src/Integration/Configuration.php +++ b/src/Integration/Configuration.php @@ -48,10 +48,8 @@ public function get($key, $default = null) /** @var string */ $index = $keys[(int) $i]; - // TODO: Need to refactor ------ /** @phpstan-ignore-next-line */ $data = &$data[$index]; - // ----------------------------- } return $data !== null ? $data : $default; diff --git a/src/Middleware/Callback.php b/src/Middleware/Callback.php index d0e3587b..93695d88 100644 --- a/src/Middleware/Callback.php +++ b/src/Middleware/Callback.php @@ -6,7 +6,9 @@ use Psr\Http\Message\ServerRequestInterface; /** - * Converts callables into Slytherin middlewares. + * Callback + * + * A class that converts callables into Slytherin middlewares. * * @package Slytherin * @author Rougin Gutib diff --git a/src/Middleware/Delegate.php b/src/Middleware/Delegate.php index 53092c8d..57583e7c 100644 --- a/src/Middleware/Delegate.php +++ b/src/Middleware/Delegate.php @@ -3,7 +3,8 @@ namespace Rougin\Slytherin\Middleware; /** - * Calls the callback with a specified HTTP request. + * Delegate + * * NOTE: To be removed in v1.0.0. Use "Handler" instead. * * @package Slytherin diff --git a/src/Middleware/Dispatcher.php b/src/Middleware/Dispatcher.php index 6e333a1f..1b295f87 100644 --- a/src/Middleware/Dispatcher.php +++ b/src/Middleware/Dispatcher.php @@ -6,6 +6,10 @@ use Rougin\Slytherin\Http\Response; /** + * Dispatcher + * + * A sample implementation of the middleware dispatcher. + * * @package Slytherin * @author Rougin Gutib */ diff --git a/src/Middleware/Doublepass.php b/src/Middleware/Doublepass.php index 3da8d6b3..2d9c95e2 100644 --- a/src/Middleware/Doublepass.php +++ b/src/Middleware/Doublepass.php @@ -6,9 +6,12 @@ use Psr\Http\Message\ServerRequestInterface; /** + * Doublepass + * + * A backward compatible handler to double-pass middlewares. + * * @package Slytherin * @author Rougin Gutib - * @codeCoverageIgnore */ class Doublepass implements HandlerInterface { diff --git a/src/Middleware/Handler.php b/src/Middleware/Handler.php index 22878d80..0007a33d 100644 --- a/src/Middleware/Handler.php +++ b/src/Middleware/Handler.php @@ -5,9 +5,12 @@ use Psr\Http\Message\ServerRequestInterface; /** + * Handler + * + * A default route for handling the application logic. + * * @package Slytherin * @author Rougin Gutib - * @codeCoverageIgnore */ class Handler implements HandlerInterface { diff --git a/src/Middleware/Handlers/Handler030.php b/src/Middleware/Handlers/Handler030.php index 693dc8ad..5bdeb6f1 100644 --- a/src/Middleware/Handlers/Handler030.php +++ b/src/Middleware/Handlers/Handler030.php @@ -8,6 +8,10 @@ use Rougin\Slytherin\Middleware\HandlerInterface; /** + * PSR-15 Handler (v0.3.0) + * + * A handler that is backward compatible for the v0.3.0 version of "http-interop". + * * @package Slytherin * @author Rougin Gutib * @codeCoverageIgnore diff --git a/src/Middleware/Handlers/Handler041.php b/src/Middleware/Handlers/Handler041.php index 7874237c..cf907a00 100644 --- a/src/Middleware/Handlers/Handler041.php +++ b/src/Middleware/Handlers/Handler041.php @@ -7,6 +7,10 @@ use Rougin\Slytherin\Middleware\HandlerInterface; /** + * PSR-15 Handler (v0.4.1) + * + * A handler that is backward compatible for the v0.4.1 version of "http-interop". + * * @package Slytherin * @author Rougin Gutib * @codeCoverageIgnore diff --git a/src/Middleware/Handlers/Handler050.php b/src/Middleware/Handlers/Handler050.php index 5f333c20..f3fefd2c 100644 --- a/src/Middleware/Handlers/Handler050.php +++ b/src/Middleware/Handlers/Handler050.php @@ -7,6 +7,10 @@ use Rougin\Slytherin\Middleware\HandlerInterface; /** + * PSR-15 Handler (v0.5.0) + * + * A handler that is backward compatible for the v0.5.0 version of "http-interop". + * * @package Slytherin * @author Rougin Gutib * @codeCoverageIgnore diff --git a/src/Middleware/Handlers/Handler100.php b/src/Middleware/Handlers/Handler100.php index bff87f02..1fef631e 100644 --- a/src/Middleware/Handlers/Handler100.php +++ b/src/Middleware/Handlers/Handler100.php @@ -8,6 +8,10 @@ use Rougin\Slytherin\Middleware\HandlerInterface; /** + * PSR-15 Handler (v1.0.0) + * + * A handler that is backward compatible for the official implementation of PSR-15. + * * @package Slytherin * @author Rougin Gutib * @codeCoverageIgnore diff --git a/src/Middleware/Interop.php b/src/Middleware/Interop.php index ebf4190b..b02d7125 100644 --- a/src/Middleware/Interop.php +++ b/src/Middleware/Interop.php @@ -9,6 +9,10 @@ use Rougin\Slytherin\Middleware\Handlers\Handler100; /** + * Interop Handler + * + * A handler that allows all "http-interop" middlewares to interact with Slytherin. + * * @package Slytherin * @author Rougin Gutib * @codeCoverageIgnore diff --git a/src/Middleware/Middleware.php b/src/Middleware/Middleware.php index 9fac26fb..c06540b7 100644 --- a/src/Middleware/Middleware.php +++ b/src/Middleware/Middleware.php @@ -5,8 +5,7 @@ /** * Middleware * - * A simple implementation of a middleware dispatcher. - * NOTE: To be removed in v1.0.0. Use "Middleware\Dispatcher" instead. + * NOTE: To be removed in v1.0.0. Use "Dispatcher" instead. * * @package Slytherin * @author Rougin Gutib diff --git a/src/Middleware/Stratigility/Middleware.php b/src/Middleware/Stratigility/Middleware.php index 3c8216ed..8552fe58 100644 --- a/src/Middleware/Stratigility/Middleware.php +++ b/src/Middleware/Stratigility/Middleware.php @@ -2,18 +2,16 @@ namespace Rougin\Slytherin\Middleware\Stratigility; -use Rougin\Slytherin\Middleware\StratigilityMiddleware; +use Rougin\Slytherin\Middleware\StratigilityDispatcher; /** * Stratigility Middleware * - * A simple implementation of middleware that is built on top of Stratigility. * NOTE: To be removed in v1.0.0. Use "Middleware\StratigilityDispatcher" instead. * * @package Slytherin * @author Rougin Gutib - * @link https://github.com/zendframework/zend-stratigility */ -class Middleware extends StratigilityMiddleware +class Middleware extends StratigilityDispatcher { } diff --git a/src/Middleware/StratigilityDispatcher.php b/src/Middleware/StratigilityDispatcher.php index ca640550..f218cd50 100644 --- a/src/Middleware/StratigilityDispatcher.php +++ b/src/Middleware/StratigilityDispatcher.php @@ -18,7 +18,8 @@ * * @package Slytherin * @author Rougin Gutib - * @link https://github.com/zendframework/zend-stratigility + * + * @link https://github.com/zendframework/zend-stratigility */ class StratigilityDispatcher extends Dispatcher { diff --git a/src/Middleware/StratigilityMiddleware.php b/src/Middleware/StratigilityMiddleware.php index 4f1a97d5..95dbde79 100644 --- a/src/Middleware/StratigilityMiddleware.php +++ b/src/Middleware/StratigilityMiddleware.php @@ -5,13 +5,11 @@ /** * Stratigility Middleware * - * A simple implementation of middleware that is built on top of Zend's Stratigility. - * NOTE: To be removed in v1.0.0. Use "Middleware\StratigilityDispatcher" instead. + * NOTE: To be removed in v1.0.0. Use "Stratigility\Middleware" instead. * * @package Slytherin * @author Rougin Gutib - * @link https://github.com/zendframework/zend-stratigility */ -class StratigilityMiddleware extends StratigilityDispatcher +class StratigilityMiddleware extends Stratigility\Middleware { } diff --git a/src/Middleware/Vanilla/Delegate.php b/src/Middleware/Vanilla/Delegate.php index 665c673b..90c4b25a 100644 --- a/src/Middleware/Vanilla/Delegate.php +++ b/src/Middleware/Vanilla/Delegate.php @@ -2,18 +2,16 @@ namespace Rougin\Slytherin\Middleware\Vanilla; -use Rougin\Slytherin\Middleware\VanillaDelegate; +use Rougin\Slytherin\Middleware\Delegate as Slytherin; /** * Delegate * - * Calls the callback with a specified HTTP request. - * NOTE: To be removed in v1.0.0. Use "Middleware\Delegate" instead. + * NOTE: To be removed in v1.0.0. Use "Delegate" instead. * * @package Slytherin * @author Rougin Gutib - * @author Rasmus Schultz */ -class Delegate extends VanillaDelegate +class Delegate extends Slytherin { } diff --git a/src/Middleware/Vanilla/Middleware.php b/src/Middleware/Vanilla/Middleware.php index 2611b8e9..ca7e1250 100644 --- a/src/Middleware/Vanilla/Middleware.php +++ b/src/Middleware/Vanilla/Middleware.php @@ -2,18 +2,16 @@ namespace Rougin\Slytherin\Middleware\Vanilla; -use Rougin\Slytherin\Middleware\VanillaMiddleware; +use Rougin\Slytherin\Middleware\Middleware as Slytherin; /** * Middleware * - * A simple implementation of a middleware on PSR-15. - * NOTE: To be removed in v1.0.0. Use "Middleware\Dispatcher" instead. + * NOTE: To be removed in v1.0.0. Use "Middleware" instead. * * @package Slytherin * @author Rougin Gutib - * @author Rasmus Schultz */ -class Middleware extends VanillaMiddleware +class Middleware extends Slytherin { } diff --git a/src/Middleware/VanillaDelegate.php b/src/Middleware/VanillaDelegate.php index 27081997..e0da8f42 100644 --- a/src/Middleware/VanillaDelegate.php +++ b/src/Middleware/VanillaDelegate.php @@ -3,12 +3,13 @@ namespace Rougin\Slytherin\Middleware; /** - * Calls the callback with a specified HTTP request. - * NOTE: To be removed in v1.0.0. Use "Middleware\Delegate" instead. + * Delegate + * + * NOTE: To be removed in v1.0.0. Use "Vanilla\Delegate" instead. * * @package Slytherin * @author Rougin Gutib */ -class VanillaDelegate extends Delegate +class VanillaDelegate extends Vanilla\Delegate { } diff --git a/src/Middleware/VanillaMiddleware.php b/src/Middleware/VanillaMiddleware.php index 6be7a360..a93708ee 100644 --- a/src/Middleware/VanillaMiddleware.php +++ b/src/Middleware/VanillaMiddleware.php @@ -5,12 +5,11 @@ /** * Middleware * - * A simple implementation of a middleware. - * NOTE: To be removed in v1.0.0. Use "Middleware\Dispatcher" instead. + * NOTE: To be removed in v1.0.0. Use "Vanilla\Middleware" instead. * * @package Slytherin * @author Rougin Gutib */ -class VanillaMiddleware extends Middleware +class VanillaMiddleware extends Vanilla\Middleware { } diff --git a/src/Middleware/Version.php b/src/Middleware/Version.php index 5775f4d8..d6a9b1f4 100644 --- a/src/Middleware/Version.php +++ b/src/Middleware/Version.php @@ -3,6 +3,10 @@ namespace Rougin\Slytherin\Middleware; /** + * Version + * + * A simple class for getting the current installed version of "http-interop". + * * @package Slytherin * @author Rougin Gutib */ diff --git a/src/Middleware/Wrapper.php b/src/Middleware/Wrapper.php index 66f4afcb..4ad5abc9 100644 --- a/src/Middleware/Wrapper.php +++ b/src/Middleware/Wrapper.php @@ -5,7 +5,9 @@ use Psr\Http\Message\ServerRequestInterface; /** - * Converts various middlewares into Slytherin counterparts. + * Wrapper + * + * A middleware that converts various middlewares into its Slytherin counterpart. * * @package Slytherin * @author Rougin Gutib diff --git a/src/Routing/RouteInterface.php b/src/Routing/RouteInterface.php index 93a17080..fb66a896 100644 --- a/src/Routing/RouteInterface.php +++ b/src/Routing/RouteInterface.php @@ -3,6 +3,10 @@ namespace Rougin\Slytherin\Routing; /** + * Route Interface + * + * An interface for handling the HTTP routes. + * * @package Slytherin * @author Rougin Gutib */ diff --git a/src/System/Endofline.php b/src/System/Endofline.php index 7af3de8e..99920e4a 100644 --- a/src/System/Endofline.php +++ b/src/System/Endofline.php @@ -7,6 +7,10 @@ use Rougin\Slytherin\Middleware\HandlerInterface; /** + * End of Line (EOL) + * + * A handler that only returns an empty HTTP response. + * * @package Slytherin * @author Rougin Gutib */ diff --git a/src/System/Handler.php b/src/System/Handler.php index fd23a2d8..2baef781 100644 --- a/src/System/Handler.php +++ b/src/System/Handler.php @@ -10,6 +10,8 @@ use Rougin\Slytherin\System; /** + * Callback Handler + * * Builds the final callback after handling from application. * * @package Slytherin diff --git a/src/System/Resolver.php b/src/System/Resolver.php index ebea36b4..046eefc3 100644 --- a/src/System/Resolver.php +++ b/src/System/Resolver.php @@ -8,6 +8,10 @@ use Rougin\Slytherin\Container\ReflectionContainer; /** + * Resolver + * + * Resolves the identifier from the container. + * * @package Slytherin * @author Rougin Gutib */