Repository navigation
feat(phpstan): analyse Latte templates - #41
Merged
Merged
Conversation
…rminating render methods
…ctors Presenters that define their own constructor without calling parent left the typed property uninitialized. Keep the runtime property untyped and document the TemplateScope type in PHPDoc; static analysis still resolves it.
GiftsPresenter::onStartup() overrides OpenVKPresenter::onStartup() and only calls parent::onStartup(), but the collected context for the override does not include variables assigned by the parent method body. Union the onStartup()/onBeforeRender() context of every ancestor as well, so presenter-wide variables such as thisUser survive lifecycle overrides.
- Do not report latte.cannotResolve when an explicit engine render was already collected for the method. - Report a missing explicit render as latte.notFound instead of silently skipping it. - Do not append .latte to _template values; Router falls back to the default template when the exact path does not exist.
Add an explicit ->render() method with no default template, a _template override, and a template using the lifecycle-provided csrfToken. These paths are now checked by the examples PHPStan job.
Keep the master dependency versions and add only the phpstan-latte dev package and its direct dependencies.
Document the default-template over-approximation, the actual Router action casing, and the class-string contract of methodMayRenderNothing().
…enders Declare SimplePresenter terminators for the examples config, add a notFound()-only action, render the explicit fixture before onBeforeRender without csrfToken, and stop Router after the direct render.
Move the Chandler\PHPStanLatte PSR-4 mapping from autoload-dev to autoload so installed applications can reference the resolver services. Analyse the tools directory and document the VCS repository, terminating methods and the current _templatePath/theme limitation.
veselcraft
previously requested changes
Oct 29, 2026
WerySkok
dismissed
veselcraft’s stale review
October 30, 2026 11:12
Согласился с ответом в телеграме
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR добавляет анализ Latte-шаблонов в PHPStan. PHPStan проверяет шаблоны презентеров, layout-шаблоны и error-страницы.
Зачем: CI теперь находит ошибки в шаблонах. Раньше такие ошибки обнаруживались только в рантайме, выливаясь в 500 Server Error. Примеры ошибок: неизвестная переменная, неверный параметр include, отсутствующий шаблон.
Для работы проверки был взят плагин efabrica-team/phpstan-latte и вайб-форкнут для поддержки Latte 3.1.
Из нюансов: шаблоны в темах пока не анализируются.