zendframework / zend-coding-standard

Zend Framework Coding Standard
BSD 3-Clause "New" or "Revised" License
35 stars 8 forks source link

[WIP] Extended Zend Framework Coding Standard #1

Closed michalbundyra closed 5 years ago

michalbundyra commented 7 years ago

Work in progress

Just want to know what you guys thinks about it.

Basically @weierophinney asked me to add just detection for unused imports. I went "a bit" more far with it and I've added much more rules. I found easy way how we can write custom rules and we don't need to copy them to Standards directory.

List what we have there now:

I would like to add also some more rules/sniffs:

Of course would be nice to have also tests for all of our custom sniffs...

So as you can see it's quite long list. Can you think about anything else what will be worth to add?

Let me know what do you think. Thanks!

/cc @weierophinney @Koopzington @xtreamwayz

mrVrAlex commented 6 years ago

Allowed, but not required.

Exactly, I agree

Why you think what space between parentheses and colon makes more sense (even in RFC no spaces in examples))? Awaiting PSR12 & ZCS ;)

Ocramius commented 6 years ago

Why you think what space between parentheses and colon makes more sense (even in RFC no spaces in examples))?

Mostly for readability purposes. It's a heated topic, like most CS rules, but doctrine/coding-standard also enforces the ) : foo { style

mrVrAlex commented 6 years ago

Well, if such expert "mastodon" like Ocramius for space, then I am fully convinced. ))

grizzm0 commented 6 years ago

You would never see a space before ":" while writing which makes it feels really "unnatural" to do so. Atleast for me. That's why my vote is for function(Foo $bar): Baz {}.

There's also no space before ":" in a switch case, before ":" in if (): (short syntax) nor before a scope resolution operator (::).

If you would describe the function in writing you would type The function Foo should return: Bar not The function Foo should return : Bar

weierophinney commented 6 years ago

You would never see a space before ":" while writing which makes it feels really "unnatural" to do so. Atleast for me. That's why my vote is for function(Foo $bar): Baz {}.

You do see it with ternary statements, however: $x ? $y : $z.

Personally, I find the whitespace surrounding it makes it harder to accidentally omit when adding your return type, leading to fewer mistakes.

Regardless of either of our own personal preferences, we will follow the guidelines of PSR-12 once it's finalized. (Interestingly, this is one of the very topics that forced it back into draft status, as quite a number of people prefer spaces surrounding the : when defining return types; the WG for the spec is debating that, and several other items, currently.)

tux-rampage commented 5 years ago

Is this still a thing since #5 (that seems to fulfill the same purpose) was merged?

michalbundyra commented 5 years ago

It's not. All work done here has been moved to https://github.com/webimpress/coding-standard