Skip to content
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

Allow "final" modifier when importing a method from a trait #11388

Closed
nicolas-grekas opened this issue Jun 7, 2023 · 1 comment · Fixed by #11394
Closed

Allow "final" modifier when importing a method from a trait #11388

nicolas-grekas opened this issue Jun 7, 2023 · 1 comment · Fixed by #11394

Comments

@nicolas-grekas
Copy link
Contributor

nicolas-grekas commented Jun 7, 2023

Description

Not sure why this is not allowed currently, but it'd be nice allowing it if there aren't any blockers:

trait SomeTrait {
    function someMethod() {}
}

class SomeClass {
    use SomeTrait {
        someMethod as final;
    }
}

This currently produces: "Cannot use 'final' as method modifier"

@nielsdos
Copy link
Member

nielsdos commented Jun 7, 2023

Following https://wiki.php.net/rfc/horizontalreuse (which introduced traits), this should be allowed.
The implementation was refactored in 3f8c729. That commit is the first time the "final" check appears AFAICT, but no reason was given for why. That commit seems to have landed in 5.4.11 and the NEWS for that version doesn't seem to mention something relevant to the behaviour change. I'll check what happens if we remove the check.

nielsdos added a commit to nielsdos/php-src that referenced this issue Jun 7, 2023
Fixes phpGH-11388.

Following https://wiki.php.net/rfc/horizontalreuse which introduced traits,
this should be allowed.
The implementation was refactored in 3f8c729. That commit is the first time
the "final" check appears AFAICT, but no reason was given for why. That
commit seems to have landed in 5.4.11 and the NEWS for that version doesn't
seem to mention something relevant to the behaviour change.
This patch removes the restriction of the final modifier.
nielsdos added a commit to nielsdos/php-src that referenced this issue Jun 7, 2023
Fixes phpGH-11388.

Following https://wiki.php.net/rfc/horizontalreuse which introduced traits,
this should be allowed.
The implementation was refactored in 3f8c729. That commit is the first time
the "final" check appears AFAICT, but no reason was given for why. That
commit seems to have landed in 5.4.11 and the NEWS for that version doesn't
seem to mention something relevant to the behaviour change.
This patch removes the restriction of the final modifier.

Closes phpGH-11394.
nielsdos added a commit that referenced this issue Jun 7, 2023
Fixes GH-11388.

Following https://wiki.php.net/rfc/horizontalreuse which introduced traits,
this should be allowed.
The implementation was refactored in 3f8c729. That commit is the first time
the "final" check appears AFAICT, but no reason was given for why. That
commit seems to have landed in 5.4.11 and the NEWS for that version doesn't
seem to mention something relevant to the behaviour change.
This patch removes the restriction of the final modifier.

Closes GH-11394.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants