Skip to content

Conversation

@ircmaxell
Copy link
Owner

Proof of concept, feedback requested. /cc @eric-therond

Copy link
Contributor

@eric-therond eric-therond left a comment

Choose a reason for hiding this comment

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

I like the idea,
It looks good, I left two comments.


if ($op instanceof Op\Stmt\Function_ || $op instanceof Op\Stmt\Class_ || $op instanceof Op\Stmt\Property || $op instanceof Op\Expr\Param) {
if ($op instanceof Op\AttributableOp) {
$result .= $this->renderAttrGroups($op->attrGroups);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$result .= $this->renderAttrGroups($op->attrGroups);
$result .= $this->renderAttrGroups($op->getAttributeGroups());

and then the attrGroups property can be made private?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Refactored a bit more, would love some more eyes

Copy link
Contributor

@eric-therond eric-therond left a comment

Choose a reason for hiding this comment

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

Looks good.
This is the first time I've seen traits in action, I don't have a lot to say but it helps a lot to factorize code.

$this->byRef = $byRef;
$this->variadic = $variadic;
$this->attrGroups = $attrGroups;
$this->setAttributeGroups(...$attrGroups);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why using the ... operator? $attrGroups is defined as an array on the __construct param.

Copy link
Owner Author

Choose a reason for hiding this comment

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

To provide type safety. setAttributeGroups is defined as setAttributeGroups(AttributeGroup ... $attrGroups)... There are def other ways, but that was the intent here.

Remove unused imports

Co-authored-by: eric-therond <[email protected]>
@ircmaxell
Copy link
Owner Author

Merging

@ircmaxell ircmaxell merged commit 7a9599e into master Aug 20, 2025
10 checks passed
@ircmaxell ircmaxell deleted the attributes branch August 20, 2025 18:54
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.

3 participants