diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e38d456..da38e0a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,17 +6,10 @@ jobs: tests: name: Tests PHP ${{ matrix.php }} runs-on: ubuntu-latest - continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false matrix: - php: [7.3, 7.4, 8.0] - experimental: [false] - include: - - php: 8.0 - analysis: true - - php: 8.1 - experimental: true + php: [7.4, 8.0, 8.1] steps: - name: Checkout diff --git a/README.md b/README.md index 26ba841..412fbf7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Via [Composer](https://getcomposer.org/) $ composer require slim/twig-view:^3.0 ``` -Requires Slim Framework 4, Twig 3 and PHP 7.3 or newer. +Requires Slim Framework 4, Twig 3 and PHP 7.4 or newer. ## Usage diff --git a/composer.json b/composer.json index 184ad53..af55487 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^7.3 || ^8.0", + "php": "^7.4 || ^8.0", "psr/http-message": "^1.0", "slim/slim": "^4.9", "twig/twig": "^3.3", diff --git a/src/Twig.php b/src/Twig.php index 3e29f26..3b8c3ef 100644 --- a/src/Twig.php +++ b/src/Twig.php @@ -46,24 +46,20 @@ class Twig implements ArrayAccess { /** * Twig loader - * - * @var LoaderInterface */ - protected $loader; + protected LoaderInterface $loader; /** * Twig environment - * - * @var Environment */ - protected $environment; + protected Environment $environment; /** * Default view variables * * @var array */ - protected $defaultVariables = []; + protected array $defaultVariables = []; /** * @param ServerRequestInterface $request diff --git a/src/TwigMiddleware.php b/src/TwigMiddleware.php index 0e47fd4..01e8392 100644 --- a/src/TwigMiddleware.php +++ b/src/TwigMiddleware.php @@ -20,25 +20,13 @@ class TwigMiddleware implements MiddlewareInterface { - /** - * @var Twig - */ - protected $twig; + protected Twig $twig; - /** - * @var RouteParserInterface - */ - protected $routeParser; + protected RouteParserInterface $routeParser; - /** - * @var string - */ - protected $basePath; + protected string $basePath; - /** - * @var string|null - */ - protected $attributeName; + protected ?string $attributeName; /** * @param App $app @@ -108,7 +96,12 @@ public function __construct( } /** - * {@inheritdoc} + * Process an incoming server request. + * + * @param ServerRequestInterface $request + * @param RequestHandlerInterface $handler + * + * @return ResponseInterface */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { diff --git a/src/TwigRuntimeExtension.php b/src/TwigRuntimeExtension.php index 88aefe7..13926c8 100644 --- a/src/TwigRuntimeExtension.php +++ b/src/TwigRuntimeExtension.php @@ -15,20 +15,11 @@ class TwigRuntimeExtension { - /** - * @var RouteParserInterface - */ - protected $routeParser; + protected RouteParserInterface $routeParser; - /** - * @var string - */ - protected $basePath = ''; + protected string $basePath = ''; - /** - * @var UriInterface - */ - protected $uri; + protected UriInterface $uri; /** * @param RouteParserInterface $routeParser Route parser diff --git a/src/TwigRuntimeLoader.php b/src/TwigRuntimeLoader.php index 4c003a7..2ac9c08 100644 --- a/src/TwigRuntimeLoader.php +++ b/src/TwigRuntimeLoader.php @@ -16,20 +16,11 @@ class TwigRuntimeLoader implements RuntimeLoaderInterface { - /** - * @var RouteParserInterface - */ - protected $routeParser; + protected RouteParserInterface $routeParser; - /** - * @var UriInterface - */ - protected $uri; + protected UriInterface $uri; - /** - * @var string - */ - protected $basePath = ''; + protected string $basePath = ''; /** * TwigRuntimeLoader constructor. @@ -46,7 +37,11 @@ public function __construct(RouteParserInterface $routeParser, UriInterface $uri } /** - * {@inheritdoc} + * Create the runtime implementation of a Twig element. + * + * @param string $class + * + * @return mixed */ public function load(string $class) { diff --git a/tests/TwigRuntimeExtensionTest.php b/tests/TwigRuntimeExtensionTest.php index fd8d4d2..8241971 100644 --- a/tests/TwigRuntimeExtensionTest.php +++ b/tests/TwigRuntimeExtensionTest.php @@ -66,7 +66,7 @@ protected function mapRouteCollectorRoute( return $route; } - public function isCurrentUrlProvider() + public function isCurrentUrlProvider(): array { return [ ['/hello/{name}', ['name' => 'world'], '/hello/world', '/base-path', true], @@ -109,7 +109,7 @@ public function testIsCurrentUrl(string $pattern, array $data, string $path, ?st $this->assertEquals($expected, $result); } - public function currentUrlProvider() + public function currentUrlProvider(): array { return [ ['/hello/{name}', 'http://example.com/hello/world?a=b', '', true], @@ -164,7 +164,7 @@ public function testCurrentUrl(string $pattern, string $url, string $basePath, b $this->assertEquals($expected, $result); } - public function urlForProvider() + public function urlForProvider(): array { return [ ['/hello/{name}', ['name' => 'world'], [], '', '/hello/world'], @@ -204,7 +204,7 @@ public function testUrlFor( $this->assertEquals($expectedUrl, $extension->urlFor($routeName, $routeData, $queryParams)); } - public function fullUrlForProvider() + public function fullUrlForProvider(): array { return [ ['/hello/{name}', ['name' => 'world'], [], '', 'http://localhost/hello/world'],