Skip to content

Commit c40d3a9

Browse files
committed
Allow php8 and update dev dependencies
1 parent 302473d commit c40d3a9

3 files changed

Lines changed: 27 additions & 24 deletions

File tree

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
}
2626
],
2727
"require": {
28-
"php": "~7.2",
28+
"php": "^7.4|^8.0",
2929

30-
"twig/twig": "~2.11|~3.0"
30+
"twig/twig": "^2.11|^3.0"
3131
},
3232
"require-dev": {
33-
"doctrine/coding-standard": "^6.0",
33+
"doctrine/coding-standard": "^9.0",
3434
"roave/security-advisories": "dev-master",
3535
"squizlabs/php_codesniffer": "^3.4",
36-
"phpstan/phpstan": "^0.11.16",
37-
"phpstan/phpstan-deprecation-rules": "^0.11.2",
38-
"phpstan/phpstan-phpunit": "^0.11.2",
39-
"phpstan/phpstan-strict-rules": "^0.11.1",
40-
"maglnet/composer-require-checker": "^2.0",
41-
"phpunit/phpunit": "^8.4"
36+
"phpstan/phpstan": "^1.4",
37+
"phpstan/phpstan-deprecation-rules": "^1.0",
38+
"phpstan/phpstan-phpunit": "^1.0",
39+
"phpstan/phpstan-strict-rules": "^1.1",
40+
"maglnet/composer-require-checker": "^2.0|^3.8|^4.0",
41+
"phpunit/phpunit": "^9.5"
4242
},
4343
"autoload": {
4444
"psr-4": {

src/Twig/Loader/StringLoader.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
use Twig\Error\LoaderError;
88
use Twig\Loader\LoaderInterface;
99
use Twig\Source;
10+
1011
use function md5;
1112
use function preg_match;
1213
use function sprintf;
1314

1415
class StringLoader implements LoaderInterface
1516
{
1617
/**
17-
* @inheritDoc
18+
* @phpstan-param string $name
1819
*/
19-
public function getSourceContext($name) : Source
20+
public function getSourceContext($name): Source
2021
{
2122
if (! $this->exists($name)) {
2223
throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
@@ -26,9 +27,9 @@ public function getSourceContext($name) : Source
2627
}
2728

2829
/**
29-
* @inheritdoc
30+
* @phpstan-param string $name
3031
*/
31-
public function getCacheKey($name) : string
32+
public function getCacheKey($name): string
3233
{
3334
if (! $this->exists($name)) {
3435
throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
@@ -38,9 +39,10 @@ public function getCacheKey($name) : string
3839
}
3940

4041
/**
41-
* @inheritdoc
42+
* @phpstan-param string $name
43+
* @phpstan-param int $time
4244
*/
43-
public function isFresh($name, $time) : bool
45+
public function isFresh($name, $time): bool
4446
{
4547
if (! $this->exists($name)) {
4648
throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
@@ -50,9 +52,9 @@ public function isFresh($name, $time) : bool
5052
}
5153

5254
/**
53-
* @inheritDoc
55+
* @phpstan-param string $name
5456
*/
55-
public function exists($name) : bool
57+
public function exists($name): bool
5658
{
5759
return (bool) preg_match('/\s/', $name);
5860
}

tests/Twig/Loader/StringLoaderTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,52 @@
77
use PHPUnit\Framework\TestCase;
88
use Shapecode\Twig\Loader\StringLoader;
99
use Twig\Error\LoaderError;
10+
1011
use function time;
1112

1213
class StringLoaderTest extends TestCase
1314
{
14-
public function testGetSourceContextWhenTemplateDoesNotExist() : void
15+
public function testGetSourceContextWhenTemplateDoesNotExist(): void
1516
{
1617
$this->expectException(LoaderError::class);
1718
$loader = new StringLoader();
1819
$loader->getSourceContext('foo');
1920
}
2021

21-
public function testGetCacheKey() : void
22+
public function testGetCacheKey(): void
2223
{
2324
$loader = new StringLoader();
2425
self::assertEquals('327b6f07435811239bc47e1544353273', $loader->getCacheKey('foo bar'));
2526
}
2627

27-
public function testGetCacheKeyWhenTemplateDoesNotExist() : void
28+
public function testGetCacheKeyWhenTemplateDoesNotExist(): void
2829
{
2930
$this->expectException(LoaderError::class);
3031
$loader = new StringLoader();
3132
$loader->getCacheKey('foo');
3233
}
3334

34-
public function testIsFresh() : void
35+
public function testIsFresh(): void
3536
{
3637
$loader = new StringLoader();
3738
self::assertTrue($loader->isFresh('foo bar', time()));
3839
}
3940

40-
public function testIsFreshWhenTemplateDoesNotExist() : void
41+
public function testIsFreshWhenTemplateDoesNotExist(): void
4142
{
4243
$this->expectException(LoaderError::class);
4344

4445
$loader = new StringLoader();
4546
$loader->isFresh('foo', time());
4647
}
4748

48-
public function testExists() : void
49+
public function testExists(): void
4950
{
5051
$loader = new StringLoader();
5152
self::assertTrue($loader->exists('foo bar'));
5253
}
5354

54-
public function testExistsFails() : void
55+
public function testExistsFails(): void
5556
{
5657
$loader = new StringLoader();
5758
self::assertFalse($loader->exists('foo'));

0 commit comments

Comments
 (0)