Skip to content

PHP 8 attributes are highlighted as comments #1093

@cizordj

Description

@cizordj

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

PHP 8 attributes are mistakenly highlighted as comments.

Image

Attributes are a new thing in PHP, and when they came out, most text editors were showing them as 'comments'.

This is a problem because comments are harder to see depending on the theme you've selected.

To Reproduce

Chroma playground

Chroma CLI

Input text:

<?php

namespace App\Service\Invoice\PercentageCalculation;

use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;

// This is an ordinary comment
# This is another ordinary comment
/*
 * Multiline comment
 */
#[AutoconfigureTag('app.invoice_item_percentage_calc')]
interface PercentageCalcInterface
{
    public function matches(PercentageCalcRequest $req): bool;

    public function handle(PercentageCalcRequest $req): int;
}

Command:

chroma \
    -s catppuccin-latte \
    --html \
    --html-lines \
    --html-lines-table \
    --html-inline-styles \
    input.php > output.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    lexer bugHighlighting error in a lexer

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions