Skip to content

Commit

Permalink
update to latest dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklog committed Dec 2, 2023
1 parent c40d3a9 commit 4135517
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 54 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/composer.lock
/composer.phar
/vendor/
.phpunit.result.cache
/.phpunit.cache
35 changes: 20 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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
}
}
}
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 12 additions & 20 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.4/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="true" beStrictAboutCoverageMetadata="true">
<coverage/>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
22 changes: 5 additions & 17 deletions src/Twig/Loader/StringLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Twig/Loader/StringLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4135517

Please sign in to comment.