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

Order getter / setter / hasser #3330

Closed
eigan opened this issue Dec 19, 2017 · 2 comments
Closed

Order getter / setter / hasser #3330

eigan opened this issue Dec 19, 2017 · 2 comments

Comments

@eigan
Copy link

eigan commented Dec 19, 2017

Before running PHP CS Fixer:

class Foo {
    public function setTitle($title) { ... }
    public function getTitle() { ... }
    public function hasTitle(): bool { ... }
}

After running PHP CS Fixer:

class Foo {
    public function getTitle() { ... }
    public function setTitle($title) { ... }
    public function hasTitle(): bool { ... }
}

Suggested rule names: ordered_mutator_accessor, ordered_get_set_has, or ordered_class_methods.
Configuration: ['get', 'set', 'has']

Other notes

Where property is NN, the ordering should be: NN, getNN, setNN, hasNN, haveNN, xxNN

@Slamdunk
Copy link
Contributor

Slamdunk commented Dec 19, 2017

I would also suggest 'is' for the following case:

interface Foo {
    public function setValid($valid);
    public function getValid();
    public function isValid();
}

@keradus
Copy link
Member

keradus commented Dec 19, 2017

closing as duplicate of #2746, please follow that thread instead.

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

No branches or pull requests

3 participants