Skip to content

Stdlib: sprintf and printf for HTML/template formatting #89

@PurHur

Description

@PurHur

Problem

Web templates often use sprintf for safe formatting:

echo sprintf('<a href="%s">%s</a>', htmlspecialchars($url), $label);

No dedicated issue tracks sprintf/printf JIT lowering; many apps avoid implode-only pipelines.

Goal

Implement sprintf (and optionally printf) for VM + JIT with a documented format subset (%s, %d, %f, %%).

Tasks

  • VM: delegate to PHP sprintf initially or port minimal formatter
  • JIT: LLVM builder or callout to C snprintf with bounded buffer
  • Reject unsupported specifiers with clear compile/runtime errors
  • PHPT compliance cases
  • Document max output length (security)

Acceptance criteria

Reference app can format pagination links without string concatenation chains.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions