Skip to content

Require non-absolute trait method refs to be unambiguous #5232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Mar 3, 2020

Currently, when writing something like

class X {
    use T1, T2 {
       func as otherFunc;
    }
    function func() {}
}

where both T1::func() and T2::func() exist, we will simply assume that func refers to T1::func(). This is surprising, and it doesn't really make sense that this particular method gets picked.

This PR validates that non-absolute method references are unambiguous, i.e. refer to exactly one method. If there is ambiguity, it is required to write T1::func as otherFunc or similar.

I think the backwards-compatibility impact here is very low. I did not find any affected code in top 2k packages.

Copy link
Contributor

@bishopb bishopb left a comment

Choose a reason for hiding this comment

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

<3 I'm really surprised that // TODO didn't at least raise a notice.

@nikic
Copy link
Member Author

nikic commented Mar 10, 2020

As there hasn't been any negative feedback on list, I'll go ahead and merge this...

@php-pulls php-pulls closed this in fff5771 Mar 10, 2020
@carusogabriel carusogabriel added this to the PHP 8.0 milestone May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants