Skip to content

Commit

Permalink
TwigStan tweaks (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk authored and COil committed Oct 21, 2024
1 parent 25a5beb commit 40563e9
Showing 8 changed files with 19 additions and 48 deletions.
16 changes: 9 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions src/Kernel.php
Original file line number Diff line number Diff line change
@@ -5,21 +5,9 @@
namespace App;

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

final class Kernel extends BaseKernel
{
use MicroKernelTrait;

protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new class implements CompilerPassInterface {
public function process(ContainerBuilder $container): void
{
$container->getDefinition('twig')->setPublic(true);
}
});
}
}
2 changes: 0 additions & 2 deletions templates/App/Controller/ComposerAction.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends 'base.html.twig' %}

{% types { composer: 'string' } %}

{% block body %}
<div class="sub-heading">
<h2>Composer ⚡</h2>
5 changes: 0 additions & 5 deletions templates/App/Controller/FormAction.html.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{% extends 'base.html.twig' %}

{% types {
dto: 'App\\Dto\\RegisterFormDto',
form: 'Symfony\\Component\\Form\\FormView'
} %}

{% set h2 = 'Form example' %}

{% block title %}{{ h2 }} | {{ brand }}{% endblock %}
2 changes: 0 additions & 2 deletions templates/App/Controller/HomeAction.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends 'base.html.twig' %}

{% types { readme: 'string' } %}

{% block body %}
<p>This page displays the <a att="" target="_blank" href="https://github.com/strangebuzz/MicroSymfony/blob/main/README.md">
README.md</a> file of the GitHub repository.</p>
4 changes: 2 additions & 2 deletions twig-loader.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

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

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

return $kernel->getContainer()->get('twig');
return $kernel->getContainer()->get('test.service_container')->get('twig');
18 changes: 4 additions & 14 deletions twigstan.php
Original file line number Diff line number Diff line change
@@ -2,23 +2,13 @@

declare(strict_types=1);

return TwigStan\Config\TwigStanConfig::configure(__DIR__)
use TwigStan\Config\TwigStanConfig;

return TwigStanConfig::configure(__DIR__)
->reportUnmatchedIgnoredErrors(true)
->phpstanConfigurationFile(__DIR__.'/phpstan.neon')
->phpstanMemoryLimit(false)
->twigEnvironmentLoader(__DIR__.'/twig-loader.php')
->twigPaths(__DIR__.'/templates')
// ->twigPaths(__DIR__ . '/tests/EndToEnd/Types')
// ->twigExcludes('something.html.twig')
// ->phpPaths(__DIR__ . '/tests/Fixtures')
// ->phpExcludes('something.php')
// ->ignoreErrors(
// TwigStan\Error\IgnoreError::create('#SomeOther#', 'someIdentifier.someValue', __DIR__ . '/some/path.php'),
// TwigStan\Error\IgnoreError::message('#SomePattern#'),
// TwigStan\Error\IgnoreError::identifier('someIdentifier'),
// TwigStan\Error\IgnoreError::path(__DIR__ . '/some/path.php'),
// TwigStan\Error\IgnoreError::messageAndIdentifier('#SomePattern#', 'someIdentifier'),
// TwigStan\Error\IgnoreError::messageAndPath('#SomePattern#', __DIR__ . '/some/path.php'),
// TwigStan\Error\IgnoreError::identifierAndPath('someIdentifier', __DIR__ . '/some/path.php'),
// )
->phpPaths(__DIR__.'/src/Controller')
->create();
8 changes: 4 additions & 4 deletions vendor-bin/php-cs-fixer/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40563e9

Please sign in to comment.