Skip to content

Commit a310c9d

Browse files
ruudkCOil
authored andcommitted
TwigStan tweaks (#99)
1 parent 83ad969 commit a310c9d

File tree

8 files changed

+32
-62
lines changed

8 files changed

+32
-62
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"require-dev": {
5050
"bamarni/composer-bin-plugin": "^1.8",
5151
"phpstan/extension-installer": "^1.3",
52-
"phpstan/phpstan-symfony": "^2.0",
52+
"phpstan/phpstan-symfony": "^1.0",
5353
"phpunit/phpunit": "^11.0",
5454
"roave/security-advisories": "dev-latest",
5555
"symfony/browser-kit": "~7.1.0",

composer.lock

Lines changed: 25 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Kernel.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,9 @@
55
namespace App;
66

77
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
8-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9-
use Symfony\Component\DependencyInjection\ContainerBuilder;
108
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
119

1210
final class Kernel extends BaseKernel
1311
{
1412
use MicroKernelTrait;
15-
16-
protected function build(ContainerBuilder $container): void
17-
{
18-
$container->addCompilerPass(new class implements CompilerPassInterface {
19-
public function process(ContainerBuilder $container): void
20-
{
21-
$container->getDefinition('twig')->setPublic(true);
22-
}
23-
});
24-
}
2513
}

templates/App/Controller/ComposerAction.html.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{% extends 'base.html.twig' %}
22

3-
{% types { composer: 'string' } %}
4-
53
{% block body %}
64
<div class="sub-heading">
75
<h2>Composer ⚡</h2>

templates/App/Controller/FormAction.html.twig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{% extends 'base.html.twig' %}
22

3-
{% types {
4-
dto: 'App\\Dto\\RegisterFormDto',
5-
form: 'Symfony\\Component\\Form\\FormView'
6-
} %}
7-
83
{% set h2 = 'Form example' %}
94

105
{% block title %}{{ h2 }} | {{ brand }}{% endblock %}

templates/App/Controller/HomeAction.html.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{% extends 'base.html.twig' %}
22

3-
{% types { readme: 'string' } %}
4-
53
{% block body %}
64
<p>This page displays the <a att="" target="_blank" href="https://github.com/strangebuzz/MicroSymfony/blob/main/README.md">
75
README.md</a> file of the GitHub repository.</p>

twig-loader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(new Dotenv())->bootEnv(__DIR__.'/.env');
1111

12-
$kernel = new Kernel($_ENV['APP_ENV'], (bool) $_ENV['APP_DEBUG']);
12+
$kernel = new Kernel('test', true);
1313
$kernel->boot();
1414

15-
return $kernel->getContainer()->get('twig');
15+
return $kernel->getContainer()->get('test.service_container')->get('twig');

twigstan.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@
22

33
declare(strict_types=1);
44

5-
return TwigStan\Config\TwigStanConfig::configure(__DIR__)
5+
use TwigStan\Config\TwigStanConfig;
6+
7+
return TwigStanConfig::configure(__DIR__)
68
->reportUnmatchedIgnoredErrors(true)
79
->phpstanConfigurationFile(__DIR__.'/phpstan.neon')
810
->phpstanMemoryLimit(false)
911
->twigEnvironmentLoader(__DIR__.'/twig-loader.php')
1012
->twigPaths(__DIR__.'/templates')
11-
// ->twigPaths(__DIR__ . '/tests/EndToEnd/Types')
12-
// ->twigExcludes('something.html.twig')
13-
// ->phpPaths(__DIR__ . '/tests/Fixtures')
14-
// ->phpExcludes('something.php')
15-
// ->ignoreErrors(
16-
// TwigStan\Error\IgnoreError::create('#SomeOther#', 'someIdentifier.someValue', __DIR__ . '/some/path.php'),
17-
// TwigStan\Error\IgnoreError::message('#SomePattern#'),
18-
// TwigStan\Error\IgnoreError::identifier('someIdentifier'),
19-
// TwigStan\Error\IgnoreError::path(__DIR__ . '/some/path.php'),
20-
// TwigStan\Error\IgnoreError::messageAndIdentifier('#SomePattern#', 'someIdentifier'),
21-
// TwigStan\Error\IgnoreError::messageAndPath('#SomePattern#', __DIR__ . '/some/path.php'),
22-
// TwigStan\Error\IgnoreError::identifierAndPath('someIdentifier', __DIR__ . '/some/path.php'),
23-
// )
13+
->phpPaths(__DIR__.'/src/Controller')
2414
->create();

0 commit comments

Comments
 (0)