Skip to content

Harden template render pipeline with precise syntax diagnostics and SAPI-safe linting#1

Draft
Copilot wants to merge 10 commits into
mainfrom
copilot/verificar-e-melhorar-estrutura
Draft

Harden template render pipeline with precise syntax diagnostics and SAPI-safe linting#1
Copilot wants to merge 10 commits into
mainfrom
copilot/verificar-e-melhorar-estrutura

Conversation

Copy link
Copy Markdown

Copilot AI commented May 27, 2026

Rendering failures were surfacing as low-signal PHP fatals, and the new pre-render lint step could misclassify Apache/mod_php process output as template syntax errors on Windows. This update makes template execution safer and ensures syntax errors are reported with actionable location details only when they are real PHP parse failures.

  • Execution model hardening

    • Replaced runtime eval execution with compiled-file materialization (tpl_<sha256>.php) + isolated include scope.
    • Kept deterministic compiled artifacts and reduced runtime ambiguity in stack traces.
  • Pre-render syntax diagnostics

    • Added explicit syntax validation for compiled template files before execution.
    • SyntaxException now includes: compiled file path, line, column (best-effort), source snippet, and parser output.
    • Prevents invalid compiled templates from entering cache by caching only after successful render.
  • SAPI-safe lint command resolution

    • Added robust PHP CLI binary selection (PHP_BINARY only if it is actually a PHP executable, then PHP_BINDIR/php(.exe), then PATH fallback).
    • Ignores non-syntax process output (e.g., Apache AH02965) to avoid false-positive SyntaxException in web SAPIs.
  • Error boundary consistency

    • Engine now catches \Throwable during render path wrapping, so parse/runtime errors are normalized into ViewException with original cause chaining.
throw new SyntaxException(
    "Compiled template syntax error in '{$templateFile}' at line {$line}, column {$column}." .
    ($snippet !== '' ? " Snippet: {$snippet}" : '') .
    ($output !== '' ? " PHP lint: {$output}" : '')
);

Copilot AI changed the title Stabilize template engine pipeline (lexer/parser/compiler) and harden runtime path/cache handling refactor: self-compiling nodes, NodeVisitor pattern, thin Compiler orchestrator May 27, 2026
Copilot AI requested a review from beobles May 27, 2026 02:21
Copilot AI changed the title refactor: self-compiling nodes, NodeVisitor pattern, thin Compiler orchestrator Remove Beobles namespace prefix and standardize on Core\View May 27, 2026
Copilot AI changed the title Remove Beobles namespace prefix and standardize on Core\View Handle extends/import directives as full statements during lexing May 27, 2026
Copilot AI changed the title Handle extends/import directives as full statements during lexing Implement real extends inheritance and correct <Block> rendering semantics May 27, 2026
Copilot AI changed the title Implement real extends inheritance and correct <Block> rendering semantics Fix template inheritance caching: invalidate child cache on parent layout changes May 27, 2026
Copilot AI changed the title Fix template inheritance caching: invalidate child cache on parent layout changes Fortalecer herança/caching de templates e endurecer parser/lexer para sintaxe confiável May 27, 2026
Copilot AI changed the title Fortalecer herança/caching de templates e endurecer parser/lexer para sintaxe confiável Replace eval-based template rendering with compiled-file execution May 27, 2026
Copilot AI changed the title Replace eval-based template rendering with compiled-file execution Harden template rendering with pre-include syntax validation and precise SyntaxException reporting May 27, 2026
Copilot AI changed the title Harden template rendering with pre-include syntax validation and precise SyntaxException reporting Harden template render pipeline with precise syntax diagnostics and SAPI-safe linting May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants