yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.22k stars 6.92k forks source link

Switching to PSR-2 #2747

Closed samdark closed 10 years ago

samdark commented 10 years ago

See #2743, #9

Ragazzo commented 10 years ago

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 commented 10 years ago

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

subdee commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

Vote for PSR-2

digitalkaoz commented 10 years ago

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

Ragazzo commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

+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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

+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 commented 10 years ago

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 commented 10 years ago

+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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

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

crisu83 commented 10 years ago

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

digitalkaoz commented 10 years ago

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

mgrechanik commented 10 years ago

+1 for psr 2

klevron commented 10 years ago

From @qiangxue in https://github.com/yiisoft/yii2/issues/9 :

Let's not bring up the war between tabs and spaces again

:+1:

@samdark

People just got tired and voted to accept something since it was clear there will be no 100% agreement

:+1:

This has already been discussed... I usually prefer tabs, but I don't really care : I contribute (I am forced, sometimes) on some projects which use psr2 or 4, but with 90% of shit code... I mean CS will not always make the code better, just more readable (I don't mean it is not useful)...

theill11 commented 10 years ago

I'm for tabs.. It is easy to configure in an IDE to suit your needs. Also it is more easy to navigate imo.

digitalkaoz commented 10 years ago

its not tabs vs spaces, it about following a defacto php standard

gonimar commented 10 years ago

Vote for spaces

motin commented 10 years ago

I agree with @schmunk42, @Crisu83 and others - following standards is the way to go. For those that are worried about IDE support, you should understand that standards will be the best supported in the long run.

tonydspaniard commented 10 years ago

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

Tabs vs spaces discussion on PSR mailing list never ended

IMHO all of you are right and have good reasons to pursue one way or the other. But I would also vote for standards.

tom-- commented 10 years ago

+1 for PSR-2 and spaces

PrplHaz4 commented 10 years ago

+1 for PSR-2 standards support - not looking forward to changing everything over to spaces, but it is the lowest common denominator when it comes to indentation, and it seems if we're going to deviate from standards, it makes more sense to save it for something that is more worthwhile than tabs vs spaces.

Yii2 also has a lot more community involvement than Yii1 - meaning standards will have more of an impact on community contributions and quality (ie, getting pull requests right the first time)

klimov-paul commented 10 years ago

I am for spaces usage, I have spoken my arguments back in #9.

In addition to those I can say following. I have to work both with Yii code style which uses tabs and my company code style, which is uses spaces. So to make sure code matching particular standard I have no choice but always enable "show whitespaces" in my IDE.

This is how it look with tabs: tabs

And this is the same file with spaces: spaces

My opinion latest is more pleasant.

mastermunj commented 10 years ago

Though I am not frequent contributor, I regularly use Yii & follow Yii2 development religiously. Lately I've also realized that following PSR standards is better than having custom one. It's not about superiority, but about following a standard followed by mass.

I vote for PSR standards.

bryglen commented 10 years ago

Psr standard as well. Netbeans vs phpstorm is a problem always

ghost commented 10 years ago

+1 for sticking to the psr2 standart.

index0h commented 10 years ago

+1 for PSR-2

danschmidt5189 commented 10 years ago

:+1: PSR-2

kotslon commented 10 years ago

I am not a contributor of yii - I'm just a user. And when I (as user) am choosing which framework to use for a project (in whatever language it is), one of serious arguments to support my decision (and to make it be approved by my boss or my client) is "Compatibility with de-facto industry standarts". If ($yii["PSR-2"]) { $score ++; } else { $score--; } :) Just as simple :) So, what do they say in PSR ? Spaces? So, let it be spaces. Once again: I will never ask you if yii is using tabs or spaces. I will ask "PSR-2 or not?". What do you whant to answer? "Yeah!" or "Hmm... Allmost yes, but you know, spaces suck, so ..." ? :)

andersonamuller commented 10 years ago

:+1: PSR-2

Even libraries used by Yii (Composer, Codeception, Switftmailer, Faker, Imagine) are following. How many pull requests here had to have their code style (PSR-2) fixed to match Yii2 standards? I used to like tabs also, but started following PSR-2 and now it feels just normal and I see some advantages. The majority of people in the PHP community seems to agree that following a standard is the way to go, and looks like Yii is the only one against it.

schmunk42 commented 10 years ago

Trend as of 15.03.2014 - 18:18

Vote for PSR-2 (spaces) - 20 votes

nineinchnick subdee joseph-kuruvilla digitalkaoz mikehaertl schmunk42 Crisu83 mgrechanik gonimar motin tonydspaniard tom-- PrplHaz4 klimov-paul mastermunj domokun-san index0h loloroboros kotslon andersonamuller

Vote for exisiting Yii standard (tabs) - 3 votes

lucianobaraglia Ragazzo Theill11

SonicGD commented 10 years ago

+1 for PSR-2. I also prefer tabs, but framework should follow standard.

slavcodev commented 10 years ago

+1 for PSR-2

qiangxue commented 10 years ago

Let's go for PSR-2. Can someone create a PR for this with the latest code? Thanks!

lucianobaraglia commented 10 years ago

The majority is overwhelming. Even though I don't like spaces, it seems the right way to go...

:+1:

Hope in the future the standard changes...