efabrica/phpstan-latte
Composer 安装命令:
composer require --dev efabrica/phpstan-latte
包简介
关键字:
README 文档
README
PHPStan extension to check compiled Latte templates in context of a Presenter or a Component etc. Templates are compiled to PHP code which is then analyzed with PHPStan rules according to a configured rule level and rules from loaded extensions.
The extension is based on Tomas Votruba's blog series and his packages symplify and reveal.
Features
- Supports Latte 2 and Latte 3
- Templates are analysed in context in which they are rendered (one template can be analysed with different contexts if it is used on multiple places)
- Automatically collects all existing template variables, components, simple forms, render calls,... from PHP code.
- Analyses existence and parameters of filters and functions.
- Can analyse existence and parameters of links (if you configure
applicationMapping). - Can use pre-configured latte engine from your application container (no need to configure manually)
- Analyses existence of components, forms and form fields used in template
- Analyses included templates in context of including template
- Can resolve rendered template path even from more complex expressions (but still has limitations)
- Can report unanalysed templates
- You can use annotations to fine-tuning analysis of latte templates
- If you use some non-standard and magic using rendering you can implement your own template resolvers (experimental)
Read How it works, when it doesn't, and troubleshooting
Installation
To use this extension, require it in Composer:
composer require efabrica/phpstan-latte --dev
If you also install phpstan/extension-installer then you're all set!
Manual installation
Add this line to your phpstan.neon:
includes: - vendor/efabrica/phpstan-latte/rules.neon
It is recommended to use this extension with phpstan-nette extension for better analysis of templates.
Configuration
- Latte engine configuration
- Analyser configuration
- Ignoring errors
- Link checking
- Other configuration options
If analysis reports errors about missing context (variables/components, ...) set in external packages you need to set option latte.collectedPaths as descibed in Analyser configuration.
Annotations
There are cases that cannot be resolved automatically by static analysis.
In these cases annotations line @phpstan-latte-ignore or @phpstan-latte-var could be used to guide resolvers to analyse latte templates correctly.
How to extend this extension
This extension supports only common built-in methods for resolving paths to latte files, collecting variables, components, forms etc. However, we know that in a wild there are applications which use their own methods for these purposes. That's why we create this extension extensible. See more about this topic here.
Development
If you want to contribute your PR are welcomed. If you want to discuss your idea first then create issue.
Thank you for using this package. Let us know if it helped you or what could be improved.
efabrica/phpstan-latte 适用场景与选型建议
efabrica/phpstan-latte 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.27k 次下载、GitHub Stars 达 45, 最近一次更新时间为 2022 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「static analysis」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 efabrica/phpstan-latte 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 efabrica/phpstan-latte 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 efabrica/phpstan-latte 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
TwigStan is a static analyzer for Twig templates powered by PHPStan
Sentiment analysis library for PHP.
Database Standardization and Analysis Tool for Laravel
Enforce architecture by defining modules with allowed dependencies. Detects forbidden, uncovered, missing and unused module dependencies in PHP projects.
Arc5 provides a set of static classes for the Mvc5 Framework
统计信息
- 总下载量: 12.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 45
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-18
