github-actions · GitHub

@iluuu1994

Copy link Copy Markdown

Member

…rse trees

Crell

#1 {main}

#0 %s(%d): {closure:%s:%d}(1)
#1 {main}

Copy link Copy Markdown

Contributor

Choose a reason for hiding this comment

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

I don't quite know how to read the closure reference properly. Does the (1) in the second one indicate a nesting problem?

Copy link Copy Markdown

Member Author

Choose a reason for hiding this comment

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

@iluuu1994

TimWolla

Copy link Copy Markdown

Member

Choose a reason for hiding this comment

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

Seems correct as a stop-gap measure.

@TimWolla

edorian

Copy link Copy Markdown

Member

Choose a reason for hiding this comment

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

RM approval: 👍

Thank you for sorting this out. Please make a note in NEWS (if you think it's appropriate) so we can tell people about the change in behavior.

@DanielEScherzer

Copy link Copy Markdown

Member

@iluuu1994

Copy link Copy Markdown

Member Author

@Crell Please confirm whether this is the approach you want to go with.

Crell

Copy link Copy Markdown

Contributor

Choose a reason for hiding this comment

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

It's not ideal, but seems the best option available under the circumstances. Thanks, Ilija!

@iluuu1994

Copy link Copy Markdown

Member Author

Thanks for the inputs. /cc @nikic I'm guessing PHP-Parser will want a similar patch applied.

@kubawerlos

Copy link Copy Markdown

Contributor

This makes the examples in RFC invalid. Any chance to update them?

Merged

@Crell

Copy link Copy Markdown

Contributor

I have no idea what standard procedure is here. I can update the RFC if that's appropriate, but I'm not sure if that's appropriate.

@iluuu1994

Copy link Copy Markdown

Member Author

@Crell Given this was discussed publicly I think adjusting the examples is appropriate. For the sake of transparency you may add it to a change log at the top of the page, with a link to the discussion.

@TimWolla

Copy link Copy Markdown

Member

@iluuu1994

Copy link Copy Markdown

Member Author

I'd still change the example. It's often the only thing people look at.

@Crell

Copy link Copy Markdown

Contributor

@ondrejmirtes

Copy link Copy Markdown

Contributor

Hi, is this really necessary when the parentheses do not add any value? For example if the arrow function is the last one in the chain:

$result = $input |> $foo->doFoo(...) |> fn ($x) => $foo->doBar($x);

Adding parentheses around the arrow function is now required but does not disambiguate anything.

Merged

@bwoebi

Copy link Copy Markdown

Member

We could work around this by scanning the AST of the fn body, to check whether it contains |>, but ... $input |> fn ($x) => ($x + 1 |> $foo->doFoo(...)); and $input |> fn ($x) => $x + 1 |> $foo->doFoo(...); for example are not distinguishable from the AST, even though the former would be fine ("last in chain").
There are such caveats which make it annoying; one simple rule "always parens-wrap it" is clearer.

Merged

adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request

Aug 4, 2026

Read the original on github.com ↗