From c88b0a10b7eb946f3797e6b3e598f5723c172019 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Sat, 13 Apr 2019 21:03:12 +0500 Subject: [PATCH] [Slim] Fix AbstractAuthenticator constructor TypeError (#2641) * Fix AbstractAuthenticator constructor TypeError * Refresh samples * Remove container argument reassign * Refresh samples --- .../main/resources/php-slim-server/SlimRouter.mustache | 9 ++++++--- samples/server/petstore/php-slim/lib/SlimRouter.php | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache b/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache index 9bba236a758..9ab1ed336f9 100644 --- a/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache @@ -116,14 +116,17 @@ class SlimRouter /** * Class constructor * - * @param ContainerInterface|array $container Either a ContainerInterface or an associative array of app settings + * @param ContainerInterface|array $settings Either a ContainerInterface or an associative array of app settings * * @throws InvalidArgumentException When no container is provided that implements ContainerInterface * @throws Exception When implementation class doesn't exists */ - public function __construct($container = []) + public function __construct($settings = []) { - $this->slimApp = new App($container); + $this->slimApp = new App($settings); + + // middlewares requires Psr\Container\ContainerInterface + $container = $this->slimApp->getContainer(); {{#hasAuthMethods}} $authPackage = '{{authPackage}}'; diff --git a/samples/server/petstore/php-slim/lib/SlimRouter.php b/samples/server/petstore/php-slim/lib/SlimRouter.php index 4d30e8f40a8..94fc95ef8a3 100644 --- a/samples/server/petstore/php-slim/lib/SlimRouter.php +++ b/samples/server/petstore/php-slim/lib/SlimRouter.php @@ -577,14 +577,17 @@ class SlimRouter /** * Class constructor * - * @param ContainerInterface|array $container Either a ContainerInterface or an associative array of app settings + * @param ContainerInterface|array $settings Either a ContainerInterface or an associative array of app settings * * @throws InvalidArgumentException When no container is provided that implements ContainerInterface * @throws Exception When implementation class doesn't exists */ - public function __construct($container = []) + public function __construct($settings = []) { - $this->slimApp = new App($container); + $this->slimApp = new App($settings); + + // middlewares requires Psr\Container\ContainerInterface + $container = $this->slimApp->getContainer(); $authPackage = 'OpenAPIServer\Auth'; $basicAuthenticator = function (ServerRequestInterface &$request, TokenSearch $tokenSearch) use ($authPackage) {