Skip to content

meta:view-component misses variables declared in one-line PHPDoc #2298

Description

@dereuromark

Tempest version

3.19.2

PHP version

8.5

Operating system

Linux

Description

While working on a Carve markup integration for Tempest:

tempest meta:view-component only reports @var declarations when the tag is
on a star-prefixed line inside a multiline PHPDoc block. A valid one-line
PHPDoc declaration is silently omitted.

This affects Tempest's built-in x-submit component, whose $label declaration
uses the one-line form.

Reproduction

With Tempest Framework 3.19.2 and PHP 8.5.10:

composer create-project tempest/app tempest-meta-repro
cd tempest-meta-repro
php tempest meta:view-component x-submit

Actual output:

{
    "name": "x-submit",
    "slots": [],
    "variables": []
}

The component contains:

/** @var null|string $label The submit button's label */

Changing it to the multiline form makes the variable appear:

/**
 * @var null|string $label The submit button's label
 */

Expected behavior

Both conventional PHPDoc forms should expose the same variable metadata. For
x-submit, the metadata should include $label with the label attribute
name.

Likely cause

MetaViewComponentCommand::resolveVariables() matches only lines beginning
with an optional indent followed by * @var:

->matchAll('/^\s*\*\s*@var.*$/m')

That pattern cannot match /** @var ... */.

Possible fix

Parse both one-line and multiline PHPDoc tags, ideally without making the
metadata extractor depend on a particular comment layout.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions