symplify / template-checker
v9.2.6
2021-03-08 21:02 UTC
Requires
- php: >=7.3
- nette/utils: ^3.2
- nikic/php-parser: ^4.10.4
- symfony/console: ^4.4|^5.2
- symfony/dependency-injection: ^5.2
- symfony/http-kernel: ^4.4|^5.2
- symfony/yaml: ^4.4|^5.2
- symplify/symplify-kernel: ^9.2.6
Requires (Dev)
- latte/latte: ^2.10
- nette/application: ^3.1
- phpunit/phpunit: ^9.5
- dev-main
- dev-master / 9.3.x-dev
- v9.2.6
- v9.2.5
- v9.2.4
- v9.2.3
- v9.2.2
- 9.2.1
- 9.2.0
- 9.1.9
- 9.1.8
- 9.1.7
- 9.1.6
- 9.1.5
- 9.1.4
- 9.1.3
- 9.1.1
- 9.1.0
- 9.0.50
- 9.0.49
- 9.0.48
- 9.0.47
- 9.0.46
- 9.0.45
- 9.0.44
- 9.0.43
- 9.0.42
- 9.0.41
- 9.0.40
- 9.0.39
- 9.0.38
- 9.0.37
- 9.0.36
- 9.0.35
- 9.0.34
- 9.0.33
- 9.0.32
- 9.0.31
- 9.0.30
- 9.0.29
- 9.0.28
- 9.0.27
- 9.0.26
- 9.0.25
- 9.0.24
- 9.0.23
- 9.0.22
- 9.0.21
- 9.0.20
- 9.0.19
- 9.0.18
- 9.0.17
- 9.0.16
- 9.0.15
- 9.0.14
- 9.0.13
- 9.0.12
- 9.0.11
- 9.0.10
- 9.0.9
- 9.0.8
- 9.0.7
- 9.0.6
- 9.0.5
- 9.0.4
- 9.0.3
- 9.0.2
- 9.0.1
- 9.0.0
- 9.0.0-rc1
- 9.0.0-BETA9
- 9.0.0-BETA8
- 9.0.0-BETA7
- 9.0.0-BETA6
- 9.0.0-BETA5
- 9.0.0-BETA4
- 9.0.0-BETA3
- 9.0.0-BETA2
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.59
- 0.3.52
- 0.3.51
- 0.3.50
- 0.3.49
- 0.3.48
- 0.3.47
- 0.3.46
- 0.3.45
- 0.3.44
- 0.3.43
- 0.3.42
- 0.3.41
- 0.3.40
- 0.3.39
- 0.3.38
- 0.3.37
- 0.3.36
- 0.3.35
- 0.3.34
- 0.3.33
- v0.3.32
- v0.3.31
- v0.3.30
- v0.3.29
- v0.3.28
- v0.3.27
- v0.3.26
This package is auto-updated.
Last update: 2021-03-11 14:19:04 UTC
README
检查您的TWIG模板
安装
composer require symplify/template-checker --dev
使用
检查Latte模板
- 检查现有类
- 检查现有类常量
- 检查现有静态调用
vendor/bin/template-checker check-latte-template templates
检查Twig控制器路径
final class SomeController { public function index() { return $this->render('does_path_exist.twig'); } }
vendor/bin/template-checker check-twig-render src/Controller
从Latte模板中提取静态调用到FilterProvider
您的模板中是否有静态调用?这是一个隐藏的过滤器。让我们将其解耦,以便在项目的其余部分使用DI和服务。
vendor/bin/template-checker extract-latte-static-call-to-filter templates
但这只是一个Dry Run...如何应用更改?
vendor/bin/template-checker extract-latte-static-call-to-filter templates --fix
会发生什么?静态调用将被Latte过滤器替换
# any latte file -{\App\SomeClass::someStaticMethod($value)} +{$value|someStaticMethod}
过滤器将被提供
use App\Contract\Latte\FilterProviderInterface; use App\SomeClass; final class SomeMethodFilterProvider implements FilterProviderInterface { public const FILTER_NAME = 'someMethod'; public function __invoke(string $name): int { return SomeClass::someStaticMethod($name); } public function getName(): string { return self::FILTER_NAME; } }
文件将被生成到/generated
目录中。只需更改命名空间并复制到您的流程中。
您想了解更多关于<强>清洁的Latte过滤器强>的信息吗?请阅读如何从Latte过滤器中摆脱魔法、静态和混乱
报告问题
如果您遇到错误或想请求新功能,请访问Symplify单repo问题跟踪器
贡献
此包的源码包含在Symplify单repo中。我们欢迎在symplify/symplify上为此包做出贡献。