Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build #324

Merged
merged 12 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.neon]
indent_style = tab
indent_size = 4

[composer.json]
indent_style = space
indent_size = 4
88 changes: 44 additions & 44 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
name: Tests
name: tests

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
tests:
name: Tests PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2]
include:
- php: 8.1
analysis: true

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1

- name: Coding standards
if: matrix.analysis
run: vendor/bin/phpcs

- name: Static analysis
if: matrix.analysis
run: vendor/bin/phpstan

- name: Tests
run: vendor/bin/phpunit --coverage-clover clover.xml

- name: Upload coverage results to Coveralls
if: matrix.analysis
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer require php-coveralls/php-coveralls -n -W
vendor/bin/php-coveralls --coverage_clover=clover.xml -v
tests:
name: Tests PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 7.4, 8.0, 8.1, 8.2, 8.3 ]
include:
- php: 8.2
analysis: true

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Coding standards
if: matrix.analysis
run: composer sniffer:check

- name: Static analysis
if: matrix.analysis
run: composer stan

- name: Tests
run: composer test:coverage

- name: Upload coverage results to Coveralls
if: matrix.analysis
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer require php-coveralls/php-coveralls -n -W
vendor/bin/php-coveralls --coverage_clover=build/coverage/clover.xml -v
21 changes: 16 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
.*.swp
.idea
.phpunit.result.cache
# Composer
composer.lock
/vendor

# PHPUnit
/.phpunit.cache
.phpunit.result.cache

# IDEs
/.fleet
/.idea
/.vscode

# Build artifacts and temporary files
.DS_Store
clover.xml
coverage
vendor
/build
/coverage
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Slim Framework Twig View

[![Build Status](https://travis-ci.org/slimphp/Twig-View.svg?branch=master)](https://travis-ci.org/slimphp/Twig-View)
[![Latest Version on Packagist](https://img.shields.io/github/release/slimphp/twig-view.svg)](https://packagist.org/packages/slim/Twig-View)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)
[![Build Status](https://github.com/slimphp/Twig-View/actions/workflows/tests.yml/badge.svg?branch=3.x)](https://github.com/slimphp/Twig-View/actions)
[![Coverage Status](https://coveralls.io/repos/github/slimphp/Twig-View/badge.svg?branch=3.x)](https://coveralls.io/github/slimphp/Twig-View?branch=3.x)
[![License](https://poser.pugx.org/slim/twig-view/license)](https://packagist.org/packages/slim/twig-view)
[![Total Downloads](https://img.shields.io/packagist/dt/slim/Twig-View.svg)](https://packagist.org/packages/slim/Twig-View/stats)

This is a Slim Framework view helper built on top of the Twig templating component. You can use this component to create and render templates in your Slim Framework application.

Expand All @@ -11,7 +13,7 @@ This is a Slim Framework view helper built on top of the Twig templating compone
Via [Composer](https://getcomposer.org/)

```bash
$ composer require slim/twig-view
composer require slim/twig-view
```

Requires Slim Framework 4, Twig 3 and PHP 7.4 or newer.
Expand Down
37 changes: 24 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "slim/twig-view",
"type": "library",
"description": "Slim Framework 4 view helper built on top of the Twig 3 templating component",
"keywords": ["slim","framework","view","template","twig"],
"homepage": "https://www.slimframework.com",
"license": "MIT",
"type": "library",
"keywords": [
"slim",
"framework",
"view",
"template",
"twig"
],
"authors": [
{
"name": "Josh Lockhart",
Expand All @@ -17,17 +22,18 @@
"homepage": "http://www.lgse.com"
}
],
"homepage": "https://www.slimframework.com",
"require": {
"php": "^7.4 || ^8.0",
"psr/http-message": "^1.1 || ^2.0",
"slim/slim": "^4.12",
"twig/twig": "^3.8",
"symfony/polyfill-php81": "^1.29"
"symfony/polyfill-php81": "^1.29",
"twig/twig": "^3.8"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.10.59",
"phpunit/phpunit": "^9.6 || ^10",
"psr/http-factory": "^1.0",
"squizlabs/php_codesniffer": "^3.9"
},
Expand All @@ -42,13 +48,18 @@
}
},
"scripts": {
"test": [
"@phpunit",
"@phpcs",
"@phpstan"
"sniffer:check": "phpcs --standard=phpcs.xml",
"sniffer:fix": "phpcbf --standard=phpcs.xml",
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
"test:all": [
"@sniffer:check",
"@stan",
"@test:coverage"
],
"phpunit": "phpunit",
"phpcs": "phpcs",
"phpstan": "phpstan"
"test:coverage": [
"@putenv XDEBUG_MODE=coverage",
"phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/coverage/clover.xml --coverage-html build/coverage --coverage-text"
]
}
}
File renamed without changes.
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: 8
paths:
- src
ignoreErrors:
- message: '#Method (.*) has parameter (.*) with generic class Slim\\App but does not specify its types: TContainerInterface#'
4 changes: 0 additions & 4 deletions phpstan.neon.dist

This file was deleted.

File renamed without changes.
32 changes: 16 additions & 16 deletions src/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Twig implements ArrayAccess

/**
* @param ServerRequestInterface $request
* @param string $attributeName
* @param string $attributeName
*
* @return Twig
*/
Expand All @@ -80,7 +80,7 @@ public static function fromRequest(ServerRequestInterface $request, string $attr
}

/**
* @param string|string[] $path Path(s) to templates directory
* @param string|string[] $path Path(s) to templates directory
* @param array<string, mixed> $settings Twig environment settings
*
* @throws LoaderError When the template cannot be found
Expand All @@ -104,7 +104,7 @@ public static function create($path, array $settings = []): self
}

/**
* @param LoaderInterface $loader Twig loader
* @param LoaderInterface $loader Twig loader
* @param array<string, mixed> $settings Twig environment settings
*/
public function __construct(LoaderInterface $loader, array $settings = [])
Expand Down Expand Up @@ -138,8 +138,8 @@ public function addRuntimeLoader(RuntimeLoaderInterface $runtimeLoader): void
/**
* Fetch rendered template
*
* @param string $template Template pathname relative to templates directory
* @param array<string, mixed> $data Associative array of template variables
* @param string $template Template pathname relative to templates directory
* @param array<string, mixed> $data Associative array of template variables
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
Expand All @@ -157,9 +157,9 @@ public function fetch(string $template, array $data = []): string
/**
* Fetch rendered block
*
* @param string $template Template pathname relative to templates directory
* @param string $block Name of the block within the template
* @param array<string, mixed> $data Associative array of template variables
* @param string $template Template pathname relative to templates directory
* @param string $block Name of the block within the template
* @param array<string, mixed> $data Associative array of template variables
*
* @throws Throwable When an error occurred during rendering
* @throws LoaderError When the template cannot be found
Expand All @@ -177,8 +177,8 @@ public function fetchBlock(string $template, string $block, array $data = []): s
/**
* Fetch rendered string
*
* @param string $string String
* @param array<string, mixed> $data Associative array of template variables
* @param string $string String
* @param array<string, mixed> $data Associative array of template variables
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
Expand All @@ -195,9 +195,9 @@ public function fetchFromString(string $string = '', array $data = []): string
/**
* Output rendered template
*
* @param ResponseInterface $response
* @param string $template Template pathname relative to templates directory
* @param array<string, mixed> $data Associative array of template variables
* @param ResponseInterface $response
* @param string $template Template pathname relative to templates directory
* @param array<string, mixed> $data Associative array of template variables
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
Expand Down Expand Up @@ -235,7 +235,7 @@ public function getEnvironment(): Environment
/**
* Does this collection have a given key?
*
* @param string $key The data key
* @param string $key The data key
*
* @return bool
*/
Expand Down Expand Up @@ -263,8 +263,8 @@ public function offsetGet($key)
/**
* Set collection item
*
* @param string $key The data key
* @param mixed $value The data value
* @param string $key The data key
* @param mixed $value The data value
*/
public function offsetSet($key, $value): void
{
Expand Down
16 changes: 9 additions & 7 deletions src/TwigMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

namespace Slim\Views;

use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use Slim\App;
use Slim\Interfaces\RouteCollectorProxyInterface;
use Slim\Interfaces\RouteParserInterface;

class TwigMiddleware implements MiddlewareInterface
Expand All @@ -29,7 +31,7 @@ class TwigMiddleware implements MiddlewareInterface
protected ?string $attributeName;

/**
* @param App $app
* @param App $app
* @param string $containerKey
*
* @return TwigMiddleware
Expand Down Expand Up @@ -61,8 +63,8 @@ public static function createFromContainer(App $app, string $containerKey = 'vie
}

/**
* @param App $app
* @param Twig $twig
* @param App $app
* @param Twig $twig
* @param string $attributeName
*
* @return TwigMiddleware
Expand All @@ -78,10 +80,10 @@ public static function create(App $app, Twig $twig, string $attributeName = 'vie
}

/**
* @param Twig $twig
* @param Twig $twig
* @param RouteParserInterface $routeParser
* @param string $basePath
* @param string|null $attributeName
* @param string $basePath
* @param string|null $attributeName
*/
public function __construct(
Twig $twig,
Expand All @@ -98,7 +100,7 @@ public function __construct(
/**
* Process an incoming server request.
*
* @param ServerRequestInterface $request
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
*
* @return ResponseInterface
Expand Down
Loading