Skip to content

deprecate(CodeSnippet): Mark class as deprecated for removal in next major #73

@usernane

Description

@usernane

Description

CodeSnippet is an opinionated UI component with hardcoded inline styles, a fragile line-counting mechanism, and a specific visual layout. It does not belong in a low-level DOM library.

Problems:

  • Hardcodes inline CSS (floats, borders, colors)
  • Line number counting has bugs (accumulates on repeated setCode() calls, off-by-one for empty input)
  • No syntax highlighting — just plain text with numbers
  • Any real project uses highlight.js, Prism, or Shiki instead
  • Couples presentation decisions to infrastructure

Replacement (3 lines):

$pre = new HTMLNode('pre');
$code = $pre->addChild('code', ['class' => 'language-php']);
$code->text($sourceCode);

Proposed Change

  • Mark CodeSnippet class with @deprecated annotation
  • Mark HTMLNode::codeSnippet() shortcut method as @deprecated
  • Remove both in next major version

Acceptance Criteria

  • @deprecated tag added to class and shortcut method
  • No functional changes (still works for existing users)
  • PHPDoc points to <pre><code> pattern as replacement

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions