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

Make "Add unimplemented methods" quickfix put methods in the same order than declaring interfaces #80

Open
pounard opened this issue Jul 11, 2020 · 0 comments
Labels

Comments

@pounard
Copy link

@pounard pounard commented Jul 11, 2020

I have the following interface:

interface Dispatcher
{
    public function dispatch($message, array $properties = []): void;

    public function process($message, array $properties = [], bool $withTransaction = true): void;
}

And I write the following class:

class TestDispatcher implements Dispatcher, \Countable, \IteratorAggregate
{
    // Methods are missing.
}

When I click on the "Add unimplemented methods" quickfix, methods are generated in something that looks like a random order, I end up with:

class TestDispatcher implements Dispatcher, \Countable, \IteratorAggregate
{
    public function process($message, array $properties = [], bool $withTransaction = true): void
    {}

    public function getIterator()
    {}

    public function dispatch($message, array $properties = []): void
    {}

    public function count()
    {}
}

In which:

  • order of methods are not the same as the declaring interface,
  • methods from each interface are randomly mixed.

Ideal world would sort the generated methods in the (declaring interfaces order, interface method order). I would end up with this order:

class TestDispatcher implements Dispatcher, \Countable, \IteratorAggregate
{
    public function dispatch($message, array $properties = []): void
    {}

    public function process($message, array $properties = [], bool $withTransaction = true): void
    {}

    public function count()
    {}

    public function getIterator()
    {}
}

It's not a traumatizing behaviour, I generally just re-order methods manually by copy/pasting it, but I try, most of the time, to give some kind of meaning to method order in my interfaces, and like to implement them in order. Moreover, having methods of different interfaces mixed up altogether is sometime confusing.

@pounard pounard added the enhancement label Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.