Skip to content

Conversation

@alfredomtx
Copy link

@alfredomtx alfredomtx commented Jan 13, 2026

Summary

Adds syntax highlighting for PHP 8+ named arguments in function/method calls.

Named arguments like id:, firstName:, lastName: in:

$this->users->map(fn (User $user) => new UserDTO(
    id: $user->id,
    firstName: $user->first_name,
    lastName: $user->last_name,
));

Are now highlighted with the @label token, which themes can style distinctly (e.g., JetBrains IDEs use a muted blue for these).

Implementation

Added a simple tree-sitter query that captures the name field of argument nodes:

(argument
  name: (name) @label)

The tree-sitter-php grammar already exposes the name field on argument nodes for named arguments, so no grammar changes are needed.

Test plan

  • Tested locally with zed: install dev extension
  • Named arguments now highlight correctly in PHP files

@cla-bot cla-bot bot added the cla-signed label Jan 13, 2026
@MrSubidubi MrSubidubi changed the title Add syntax highlighting for named arguments (PHP 8+) Add syntax highlighting for named arguments Jan 17, 2026
Copy link
Contributor

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Can you quickly elaborate why this shoud be highlighted as label? From an initial view, this seems unintuitive to me, but I might be lacking context here. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants