Skip to content

fix(framework): read one-line docblock vars in meta:view-component - #2299

Open
dereuromark wants to merge 2 commits into
tempestphp:3.xfrom
dereuromark:fix/meta-view-component-one-line-var
Open

dereuromark wants to merge 2 commits into
tempestphp:3.xfrom
dereuromark:fix/meta-view-component-one-line-var

Conversation

@dereuromark

Copy link
Copy Markdown

Fixes #2298

meta:view-component only picked up var tags on the star-prefixed lines of a multiline docblock. A one-line docblock was skipped, so x-submit reported no variables:

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

The extractor now reads both forms. x-submit lists $label with its description.

One-line docblocks also type local variables, as in x-input:

/** @var FormSession $formSession */
$formSession = get(FormSession::class);

A one-line var tag directly followed by a plain = assignment to the same variable is treated as a local and left out, so x-input doesn't start listing $formSession and $validator as attributes. Compound assignments like ??= still count as attributes, since that's how components set a default.

The variable extractor only matched var tags on star-prefixed lines of a
multiline docblock, so components declaring attributes in a one-line docblock
(like the built-in `x-submit` does for `$label`) reported no variables.

One-line docblocks directly followed by a plain assignment to the same
variable, such as the `$formSession = get(...)` in `x-input`, type a local and
stay excluded, so `x-input` does not suddenly list its services as attributes.
Compound assignments such as `??=` keep the variable, since they are how
components give an attribute a default.
@dereuromark
dereuromark requested a review from brendt as a code owner September 15, 2026 22:06
@brendt

brendt commented Sep 16, 2026

Copy link
Copy Markdown
Member

Could you take a look at the failing test? I assume it's something to do with line endings

With /m, `$` matches before `\n` but not before `\r`, and neither the
declaration class nor the trailing whitespace can consume a carriage
return. On a CRLF checkout (Windows CI) no multiline var tag matched and
every component reported an empty variable list.
@dereuromark

Copy link
Copy Markdown
Author

"5 workflows awaiting approval"
In settings, you can set to "approval only needed for new github users", this usually helps to speed things up.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants