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

Sort overridden methods in parent-defined order #4

Closed
erickskrauch opened this issue Dec 18, 2023 · 0 comments
Closed

Sort overridden methods in parent-defined order #4

erickskrauch opened this issue Dec 18, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@erickskrauch
Copy link
Owner

During the review, I encountered that the developer added the implementation of new methods to the end of the class, while in the interface these methods were described above. I remarked and asked to fix it for code consistency, but I realized that this is a stylistic remark, which means that it either shouldn't be made at all or should be implemented as an automatic tool.

Example

Before fix:

interface Basic {

    public function firstMethod();

    public function secondMethod();

    public function thirdMethod();

}

final class BasicImplementation implements Basic {

    public function firstMethod() {
        // Code
    }

    public function thirdMethod() { // Out of order!
        // Code
    }

    public function secondMethod() {
        // Code
    }

}

After fix:

final class BasicImplementation implements Basic {

    public function firstMethod() {
        // Code
    }

    public function secondMethod() {
        // Code
    }

    public function thirdMethod() { // Now on its place
        // Code
    }

}

Notes:

  • The implementation should work correctly with php-doc and attributes.
  • The fixer must run before ordered_class_elements.
  • The fixer should work for interfaces, extended interfaces, abstract classes, and non-final classes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant