From 4135517a990a7a89d440b99e90f87943f68ba1a0 Mon Sep 17 00:00:00 2001 From: Nikita Loges Date: Sat, 2 Dec 2023 16:18:43 +0100 Subject: [PATCH] update to latest dependencies --- .github/workflows/php.yml | 30 ++++++++++++++++++++++ .gitignore | 2 +- composer.json | 35 +++++++++++++++----------- phpstan.neon.dist | 2 +- phpunit.xml | 32 +++++++++-------------- src/Twig/Loader/StringLoader.php | 22 ++++------------ tests/Twig/Loader/StringLoaderTest.php | 2 ++ 7 files changed, 71 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..c9c9675 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,30 @@ +name: Check + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: [ '8.2', '8.3' ] + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - run: composer validate --strict -n + - run: composer install --prefer-dist --no-progress --no-suggest + - run: composer check diff --git a/.gitignore b/.gitignore index 208aa0b..0b7919a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /composer.lock /composer.phar /vendor/ -.phpunit.result.cache \ No newline at end of file +/.phpunit.cache diff --git a/composer.json b/composer.json index 53efa97..3c107df 100644 --- a/composer.json +++ b/composer.json @@ -25,20 +25,20 @@ } ], "require": { - "php": "^7.4|^8.0", + "php": "^8.1", - "twig/twig": "^2.11|^3.0" + "twig/twig": "^3.8" }, "require-dev": { - "doctrine/coding-standard": "^9.0", + "doctrine/coding-standard": "^12.0", "roave/security-advisories": "dev-master", - "squizlabs/php_codesniffer": "^3.4", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "phpstan/phpstan-strict-rules": "^1.1", - "maglnet/composer-require-checker": "^2.0|^3.8|^4.0", - "phpunit/phpunit": "^9.5" + "squizlabs/php_codesniffer": "^3.7", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan-strict-rules": "^1.5", + "maglnet/composer-require-checker": "^4.7", + "phpunit/phpunit": "^10.5" }, "autoload": { "psr-4": { @@ -53,21 +53,26 @@ "scripts": { "check": [ "@crc", - "@cs-fix", "@cs-check", - "@phpstan" + "@phpstan", + "@phpunit" ], "phpstan": "./vendor/bin/phpstan analyse ./src", "crc": "./vendor/bin/composer-require-checker --config-file=./composer-require-checker.json", - "phpunit": "./vendor/bin/phpunit", + "phpunit": "./vendor/bin/phpunit --colors=always", "cs-fix": "./vendor/bin/phpcbf", "cs-check": "./vendor/bin/phpcs -s" }, "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "minimum-stability": "dev", - "prefer-stable": true + "prefer-stable": true, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 396daed..2e81399 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,7 @@ includes: - vendor/phpstan/phpstan/conf/bleedingEdge.neon - vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-deprecation-rules/rules.neon - #- vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon parameters: diff --git a/phpunit.xml b/phpunit.xml index 295e8e9..5350ea7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,14 @@ - - - - tests - - - - - - src - - + + + + + tests + + + + + src + + diff --git a/src/Twig/Loader/StringLoader.php b/src/Twig/Loader/StringLoader.php index 5b6cca9..8f34365 100644 --- a/src/Twig/Loader/StringLoader.php +++ b/src/Twig/Loader/StringLoader.php @@ -14,10 +14,7 @@ class StringLoader implements LoaderInterface { - /** - * @phpstan-param string $name - */ - public function getSourceContext($name): Source + public function getSourceContext(string $name): Source { if (! $this->exists($name)) { throw new LoaderError(sprintf('Template "%s" is not defined.', $name)); @@ -26,10 +23,7 @@ public function getSourceContext($name): Source return new Source($name, $name); } - /** - * @phpstan-param string $name - */ - public function getCacheKey($name): string + public function getCacheKey(string $name): string { if (! $this->exists($name)) { throw new LoaderError(sprintf('Template "%s" is not defined.', $name)); @@ -38,11 +32,7 @@ public function getCacheKey($name): string return md5($name); } - /** - * @phpstan-param string $name - * @phpstan-param int $time - */ - public function isFresh($name, $time): bool + public function isFresh(string $name, int $time): bool { if (! $this->exists($name)) { throw new LoaderError(sprintf('Template "%s" is not defined.', $name)); @@ -51,10 +41,8 @@ public function isFresh($name, $time): bool return true; } - /** - * @phpstan-param string $name - */ - public function exists($name): bool + /** @phpstan-param string $name */ + public function exists(string $name): bool { return (bool) preg_match('/\s/', $name); } diff --git a/tests/Twig/Loader/StringLoaderTest.php b/tests/Twig/Loader/StringLoaderTest.php index 33fdfda..4d235cd 100644 --- a/tests/Twig/Loader/StringLoaderTest.php +++ b/tests/Twig/Loader/StringLoaderTest.php @@ -4,12 +4,14 @@ namespace Shapecode\Tests\Twig\Loader; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Shapecode\Twig\Loader\StringLoader; use Twig\Error\LoaderError; use function time; +#[CoversClass(StringLoader::class)] class StringLoaderTest extends TestCase { public function testGetSourceContextWhenTemplateDoesNotExist(): void