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

Switching to PSR-2 #2747

Closed
samdark opened this issue Mar 14, 2014 · 77 comments
Closed

Switching to PSR-2 #2747

samdark opened this issue Mar 14, 2014 · 77 comments

Comments

@samdark
Copy link
Member

@samdark samdark commented Mar 14, 2014

See #2743, #9

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

i am against spaces, in netbeans their usage is painful, also i dont think that switching PSR styles here and there is good, we should be strict in usage one of them and not jumping from one to another.

@nineinchnick
Copy link
Contributor

@nineinchnick nineinchnick commented Mar 14, 2014

Should we vote, I'm for it. I'm not bringing any arguments up, referred issues are enough.

@subdee
Copy link
Contributor

@subdee subdee commented Mar 14, 2014

I personally was hoping that Yii2 would conform to all the PSR standards, was disappointed to see that it doesn't. There's nothing wrong with conforming with a standard that's agreed upon.

Thus, I vote for PSR-2.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

definitly for psrX...working with different coding styles in one project is a pain in the ass...iteroperability ftw, thats why mostly every php library switched to it, it simply makes code formatting a no-brainer in the php world...

personal preferences should stand back on this one, every ide can handle it properly.

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

@digitalkaoz can you show me how faster you will be by browsing code with vim and PSR-2 spaces, or in netbeans IDE? So you are proposing that each programmer should be some piano master to remember all switch-combinations and use them? I also dont like arguments splitting in method signature, it only makes code unreadable.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

so you rating "browsing code without shortcuts" higher than "common readability across different libraries"? vim: alt+shift+arrays, phpstorm alt+arrows ;)

its just not a matter of personal preferences, its a matter of a common sense, correct formatting is done by some tools or your ide itself

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

yes, i rate usability higher than some ability with 3rd party libs, also you can see that there a lot of such decisions and PR in Yii2 where usability is higher then some other PSR. And you proposing to use 3-4 buttons for simple browsing? I dont like it, also remember that you can simply push some other button and consequences can be awful. How long you were using Yii? It looks like you just came and want to do everything right.

@joseph-kuruvilla
Copy link
Contributor

@joseph-kuruvilla joseph-kuruvilla commented Mar 14, 2014

Vote for PSR-2

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

yes i came by from a psrX world, where this discussion ended a few years ago in favor of a common sense ;)

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

so, @digitalkaoz you was not using Yii and just forcing idea of spaces here, right? Do you understand that there are a lot of Yii1 and Yii2 (already) projects that use tabs, and a lot of Yii developers that already use and prefere to use tabs, and now you are just suggesting them to forget everything and support a lot of projects with new formatting?
I dont think that it is good. However as you can see Yii2 has some things from PSR-2, the only thing Yii does not have is spaces, well this is for historical reasons. So i think we should first listen for developers that were using Yii for some long time, and not switching right now. Note that with IDE you will have some problem by supporting old and new Yii projects with tabs and spaces, you will need to make IDE remember 2-3 desktop settings and switch between them each time.
The thing here is that you should adopt fw style, because you use it, and not suggeting to build everything from the ground.

@subdee
Copy link
Contributor

@subdee subdee commented Mar 14, 2014

Noone is forcing anyone to do anything. Many members of great PHP projects have already accepted a standard as a way to have interoperability. It is nice to have a community that agrees on some standards that would make developer's lives easier.

The argument about Yii1 is completely irrelevant. Whoever has started a project in Yii2 should've known about the risks of starting a project with a framework that is in Alpha still. Also, suggesting that just because someone hasn't used Yii since day one, doesn't have a say in this, gives a very bad image about the Yii community in general.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

yes i am dont prejudiced against yii, but not using a common sense in the php world just sounds insane to me. its like being stuck in old paradigms

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

@digitalkaoz so you telling me that all developers switched to spaces and none use tabs? really? what common sence are you talking about? Afaik there always will be 2 points: tabs vs spaces. And since you are not using Yii and dont know its workflow you are trying to force here PSR-2. That is not good. Well as i said, i am against it, but not for me to decide ofcourse, but all this last Yii2 changes just guide fw to some madness.

@schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Mar 14, 2014

+1 for switching to PSR-2 ...

@Ragazzo What's the big deal about switching to spaces for a project once? Just run a formatter.
It is really annoying, that Yii 2 is practically the only project in your vendor folder which uses tabs rather than spaces.

There was a 50/50 chance for tabs vs. spaces in the standard, which is very widely accepted in the PHP world now. I didn't analyze ist, but I'd estimate 90% of extensions on packagist are using spaces.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

PSR-2 is a common sense, just to make php code almost the same style in every project, so our brains just dont have to fiddle around in which library we are editing right now...and yes i havent seen tabs for long time... what does a coding style has todo with a workflow of things? i have to use yii in a future project, and wondered when i started to dig into the code...

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

@schmunk42 running formatter is such a pain) also extensions should follow main fw codestyle as you know.

@digitalkaoz yeah, i read that guide, as i said i dont like attributes splitting and other things. Anyway not for me to decide.

Also what about switching Yii1 to PSR-2 then? Dont see good reasons against it, why not?))

@samdark
Copy link
Member Author

@samdark samdark commented Mar 14, 2014

@digitalkaoz

yes i came by from a psrX world, where this discussion ended a few years ago in favor of a common sense ;)

That's not entirely true. Tabs vs spaces discussion on PSR mailing list never ended. People just got tired and voted to accept something since it was clear there will be no 100% agreement. Many people from php-fig including me think PSR-2 is not perfect.

@samdark
Copy link
Member Author

@samdark samdark commented Mar 14, 2014

Also what about switching Yii1 to PSR-2 then? Dont see good reasons against it, why not?))

It's already stable. That would be very bad timing while for 2.0 it is still possible.

@schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Mar 14, 2014

@schmunk42 running formatter is such a pain) also extensions should follow main fw codestyle as you know.

Try https://github.com/fabpot/PHP-CS-Fixer and yes, that's why the FW should change here ;)

@samdark Correct. If the decision for the PHP world would have been tabs, I'd be using tabs now.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

you never get every person to fully agree with some opinions of others. but at least we had a decision.

i am against changing it for 1.x but for 2.x it really makes sense i think

@lucianobaraglia
Copy link
Contributor

@lucianobaraglia lucianobaraglia commented Mar 14, 2014

+1 For keeping tabs

What people keep saying that using spaces is common sense?
Tabs allows developer to configure the ide to show any desired width.
Tabs means smaller file size.

What if "standards" changes and tell you that you should use 3 spaces instead? Good luck with that!

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

fixing code formatting against a ruleset, is a matter of minutes nowadays...

spaces makes it readable the same on every device with every software out of the box, so its just a matter readability not a matter of personal preferences

@mikehaertl
Copy link
Contributor

@mikehaertl mikehaertl commented Mar 14, 2014

+1 for spaces.

Spaces are de-facto standard in PHP back since (I think?) 1998 when PEAR was born. And the advantages are self-evident: Spaces are unambiguous. A space is a space is a space. A tab can be everything. Given that we mix more and more foreign libraries into our projects it's a real pain to switch back and forth between standards.

And the real danger is, when you start mixing tabs with spaces (often without notice).

@schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Mar 14, 2014

@lucianobaraglia

What people keep saying that using spaces is common sense?

It is not about pro-contra features, it's just about having the same standard across the PHP world.

What if "standards" changes and tell you that you should use 3 spaces instead?

The purpose of a standard is, that these things don't change all the time!

@Ragazzo
Copy link
Contributor

@Ragazzo Ragazzo commented Mar 14, 2014

don't change all the time!

@schmunk42 you are telling this in Yii2 repo? where in last week a lot of big BC breaks occured :D

@samdark
Copy link
Member Author

@samdark samdark commented Mar 14, 2014

@Ragazzo let's keep this discussion clean from offtopic please. BC breaks aren't relevant before stable release.

@crisu83
Copy link

@crisu83 crisu83 commented Mar 14, 2014

I agree with @schmunk42. I think it should be a no-brainer to follow PSR-2.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 14, 2014

and please lets focus on psr2, psr4 is another good thing, but thats already introduced :)

@mgrechanik
Copy link
Contributor

@mgrechanik mgrechanik commented Mar 14, 2014

+1 for psr 2

@qiangxue qiangxue closed this Mar 16, 2014
samdark added a commit to yiisoft/yii2-coding-standards that referenced this issue Mar 17, 2014
@iJackUA
Copy link
Contributor

@iJackUA iJackUA commented Mar 17, 2014

Should it be removed
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
from https://github.com/yiisoft/yii2-coding-standards/blob/master/Yii2/ruleset.xml ?

@schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Mar 17, 2014

@iJackUA
Copy link
Contributor

@iJackUA iJackUA commented Mar 17, 2014

@schmunk42 no, that's another line , it is still exist in rulesset.xml

@maximal
Copy link
Contributor

@maximal maximal commented Mar 17, 2014

The most reasonable indentation style is SmartTabs: indentation with tabs, alignment with spaces.

I’m against changing Yii style to spaces only :-(

And many modern IDEs and editors do it right.

@samdark
Copy link
Member Author

@samdark samdark commented Mar 17, 2014

@maximal that's not about usability, it is about overall consistency in PHP world.

@cebe
Copy link
Member

@cebe cebe commented Mar 17, 2014

@maximal can't agree more but the majority of people seem to love standards and stick to them without questioning whether it is useful or not...

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 17, 2014

interoperability is useful, much more then personal coding style preferences ;)

@maximal
Copy link
Contributor

@maximal maximal commented Mar 17, 2014

Agree with you. Framework in any given language, probably, should use current standard for this language (PSR-2 for PHP, for instance).

But, from the other hand, why did unreasonable standard remains real then?
Standards sometimes became unuseful and vast majority of people have to follow them just to follow.
Space-only indentation is relic of the past, when people don’t know about smart-tabs indentation.

@samdark
Copy link
Member Author

@samdark samdark commented Mar 17, 2014

@maximal it's a long term holywar that resulted in spaces decision withing php-fig. I prefer any decision to no decision regarding it.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 17, 2014

you dont have to configure spaces in any editor in any os in any environment, they just look the same for everyone...

@maximal
Copy link
Contributor

@maximal maximal commented Mar 17, 2014

@digitalkaoz, anyway, I don’t know any situation when smart-tabbed text brokes its alignment.

http://www.emacswiki.org/SmartTabs

@tom--
Copy link
Contributor

@tom-- tom-- commented Mar 17, 2014

Enough

I can't think of a less interesting topic to argue about.

This is turning into another sign that it's time to move on from github.

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Mar 17, 2014

yes am also tired about discussing tabs vs spaces, it just doesnt matter, following a standard matters

@plandem
Copy link

@plandem plandem commented Mar 17, 2014

i'm for tabs, coz IDE can be configured. I'm using tabs from c/c++ times at the deep past. Spaces is pain for "fast-fixing" outside of IDE and mostly always breaks such 'nice' formatting :(

But i'm for standard here. Anyways, i'm not going to patch framework alot, so for projects i will still use tabs :)

@maximal
Copy link
Contributor

@maximal maximal commented Mar 18, 2014

Sorry, but one more try.

Tabs advantages:

  • Tabs are designed to be an indentation character.
  • Tabs can be configured to have different width.
  • Tabs keep source code size meaningful, not exaggerating characters count by 4-times with meaningless whitespace characters. With tabs, 5k file, say, is 4k source and 1k whitespace. With spaces, 5k file is 1-2 source and 4-3 k whitespace.
  • Many IDEs do the smart-tabbing automatically, making this approach transparent and clean.

Spaces advantages:

  • Code looks the same in different editors.
  • Any more? (Disregarding that they are standard, only logical and usability points).

Spaces became standard, yes. But that was strictly because people were unable to use tabs properly. That was 30-, 20-, 10-years-ago problem. But why are they unable to use tabs now, when IDEs are mighty?

The less we use tabs, the less chances they have to became standard. People now are just afraid to use them. It means that standard needs to be reviewed.

Sorry again.

@samdark
Copy link
Member Author

@samdark samdark commented Mar 18, 2014

That's the question for PSR, not for Yii. If there will be another standard with tabs we'll switch to it immediately.

@maximal
Copy link
Contributor

@maximal maximal commented Mar 18, 2014

@samdark, thank you, Alexander.

@lucianobaraglia
Copy link
Contributor

@lucianobaraglia lucianobaraglia commented Mar 18, 2014

@maximal 👍 it's amazing standards keeps defending spaces nowadays...
@samdark I hope so...you are a member of the PHP FIG, is still this discussion ( spaces VS tabs ) rising up time to time?

@samdark
Copy link
Member Author

@samdark samdark commented Mar 18, 2014

@lucianobaraglia yeah, it's still popping up from time to time but not that often and it's not as hot as it was.

@maximal
Copy link
Contributor

@maximal maximal commented Mar 18, 2014

@lucianobaraglia, thanks. I opened php-fig/fig-standards#264, but @pmjones closed the discussion.
I think it’s time to fork PSR-2 to have more competing standards :-)

If you guys have any ideas, I’m open to requests — https://github.com/maximal/tab/.

@lucianobaraglia
Copy link
Contributor

@lucianobaraglia lucianobaraglia commented Mar 18, 2014

@maximal spaces dinosaurs still rule the Earth... 😐

@kotslon
Copy link

@kotslon kotslon commented Mar 18, 2014

Hey, people! Why are you still using blank lines for readability? Maybe it's time to invent vertical tab? And why do we use spaces between words instead of \s+ ? One could config own IDE to show that symbols as exotically, as he'd like!

Seriously, i think tabs are not so widely used, because they are alone. One configurable parameter is not enough for introducing the concept of such a configurability. Maybe some day there will be more...

@alpharder
Copy link

@alpharder alpharder commented Mar 18, 2014

Why do you guys pay so much attention to this?
There are a lot of much more important things to discuss

@rawtaz
Copy link
Contributor

@rawtaz rawtaz commented Apr 20, 2014

What a great fail this is. Way to ruin a great framework.

And yes, it is obviously a very important discussion, otherwise there wouldn't be an endless stream of opinions on the topic. If it wasn't important, the discussion would die out.

There will never be a common agreement on this. Either "side" of the discussion will be unhappy, while the other is happy.

@rawtaz
Copy link
Contributor

@rawtaz rawtaz commented Apr 20, 2014

+1 for keeping tabs, even if it's too late :P

@rawtaz
Copy link
Contributor

@rawtaz rawtaz commented Apr 20, 2014

@kotslon 1) Because blank lines apparently are fine as "vertical whitespace" for most people, otherwise there would have been more discussion about it. 2) Vertical tab already exists, check your facts before typing.. 3) Same as (1). Seems you just wanted to try making this more complicated than it is, which is rather pointless. The things you mention are clearly not an issue for people, so there's no use in bringing them up.

@alpharder Because people care a lot, and because someone brought it up again in #2743. If there are, as you say, more important things to discuss, then the spaces zealots shouldn't bring this up over and over again.

There's been so much bullshit in this thread that there's no way one can comment on all of it. And obviously it doesn't matter anyway since the decision has been made. Kudos to the pro-tab people for standing up for their beliefs.

With this, I'm done.

@armab
Copy link
Contributor

@armab armab commented Apr 20, 2014

I can say I prefer Yii 1 coding style and didn't like this change,
but during time after switching to PSR-2 I feel no problems using spaces instead of tabs.

That was right decision that removes another one barrier on the way of Framework growth and popularity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

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