Repository navigation
Description
The Latte check is the one part of cli/lint.php that cannot become a dresscode rule, so it needs a home of its own once $_REQUEST and // language= move out as rules. This follows #232.
Why it cannot be a rule
dresscode parses PHP and nothing else (its docs: the grammar "is PHP and nothing else"). A rule gets a PHP syntax tree, and a .latte file does not produce one. It is not on dresscode's file list either way, since the config selects PHP files.
Why not the stock latte-lint
app/vendor/bin/latte-lint ships with Latte and is the obvious replacement, but it builds its own engine. On app/src, with Latte as locked today:
app/src/Assets/busy.latte:6 Unknown function t() on line 6 at column 74
Error: strip_tags(): Argument #1 ($string) must be of type string, null given
It exits 2 at the first of our 16 templates, so nothing after that gets checked. There are two separate causes:
- The warning:
t(),input_hidden()andinput_token()are registered inDesktop\Latte::engine(), and the stock tool does not know them. - The crash: probably the same
PHP_BINARYtrap dresscode's workers hit. The tool's engine callsenablePhpLinter(PHP_BINARY), which here is frankenphp, not aphpthat understands-l. That comes from readingLinter::createEngine(), not from a test.
Allowing unknown functions would be worse than the crash. The list in engine() is also what a template may call, so a typo like {inputToken()} has to fail here and not on someone's screen.
What to do
Keep new Latte\Tools\Linter(Desktop\Latte::engine())->scanDirectory(). Linting through the engine the app runs means the linter and the app can never disagree about what a template may call.
- Move it to
cli/latte-lint.phpwhen the other two checks have become rules, and havemake qacall that instead ofcli/lint.php. - Drop what only
cli/lint.phpneeds: the syntax check (dresscode reports a syntax error and exits 1, and phpstan fails on one too), and the branch that skips Latte whenapp/vendoris missing.qahasapp/vendoras a prerequisite, and nothing else calls the script, so that branch never runs there. - Keep the scan over all of
app/, as today, and check it still fails on a deliberately broken template and on an unknown function. A linter that quietly finds nothing looks the same as one that passes. - Update
CLAUDE.md, which namescli/lint.php.
Not in scope
Compiling templates in make bundle already fails the build on one that does not compile, and make e2e-packaged catches a template the build missed. Those run later and only on a release path, so they do not replace a check in make qa.
Activity