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

PHP Coding Standards Fixer #1

Closed
harikt opened this issue Sep 5, 2014 · 24 comments
Closed

PHP Coding Standards Fixer #1

harikt opened this issue Sep 5, 2014 · 24 comments

Comments

@harikt
Copy link

harikt commented Sep 5, 2014

Hi guys,

I do believe Nette is a great project. I do have written a few posts about tracy and neon this is an old post and need edits.

So that was to show that I do love your project, there can be other posts in http://harikt.com/blog/archives/ .

I was doing a translation

Pro někoho je volba mezery nebo tabulátoru nepodstatným detailem, pro jiného otázkou víry. Jednou používaný znak pro odsazování je nesmírně komplikované měnit, zejména u větších projektů.

and thought it is good to let you guys know about a tool called http://cs.sensiolabs.org/ when I read the below line.

For some, the choice spaces or tabs insignificant detail, for others a matter of faith. One character used for indentation is extremely difficult to change, especially for larger projects.

I don't want to quarrel here, but should take into consideration when you have a tool to fix the big projects, your adoption will only increase .

Thank you.

@dg
Copy link
Contributor

dg commented Sep 5, 2014

Technically is change very easy, it can be done via simple regexp. Problematic are converting of pull request, merging, doing blames, reverting and other Git operations. It makes this change impossible. In addition, no one has need to do this change or adopt "foreign" standard.

@harikt
Copy link
Author

harikt commented Sep 5, 2014

Thank you @dg .

@harikt
Copy link
Author

harikt commented Sep 5, 2014

In addition, no one has need to do this change or adopt "foreign" standard.

Now I understood you don't love foreign standards, but the people who use nette need to adopt the foreign standard of Nette. Good luck with your project and thanks! .

@harikt harikt closed this as completed Sep 5, 2014
@dg
Copy link
Contributor

dg commented Sep 5, 2014

Absolutely not. People who use Nette do not have to adopt Nette coding style. People who create PHP-FIG do not forces anybody to adopt they standard.

Do not take this the wrong way, but its you who don't love Nette standard and forces me to use your loved standard ;-)

@harikt
Copy link
Author

harikt commented Sep 5, 2014

@dg you should understand why the PSR-1, PSR-2 came.
I would like to take a few minutes of yours to hear http://voicesoftheelephpant.com/2012/05/01/fig-fud-fomo/
So you know people who are in open source only need to follow one standard and not swtich between different standards.

@dg
Copy link
Contributor

dg commented Sep 5, 2014

Ok. If Paul M. Jones will tell me that is good idea to change tabs to spaces in all my existing projects, I will promote this idea in Nette community. Deal?

@pmjones
Copy link

pmjones commented Sep 5, 2014

@dg : OK, here you go --

I think it is a good idea to change from tabs to spaces in all your existing projects.

We can discuss at greater length if you like. :-)

@dg
Copy link
Contributor

dg commented Sep 5, 2014

:-))) Ok, I'll promote it.

Can you help me with converting existing pull requests and convince GitHub to enable option ?w=1 by default?

@pmjones
Copy link

pmjones commented Sep 5, 2014

I have only so much time in the day, and so I cannot volunteer my services to help with your project at this time. However, I can point out that the php-cs-fixer has an option that will covert tab indentation to spaces with great ease, essentially:

php php-cs-fixer.phar fix /path/to/dir --fixers=indentation

Apply that to your project source dirs, and tell everyone their patches have to be spaces not tabs, and voila, it's all over but the arguing. ;-)

@dg
Copy link
Contributor

dg commented Sep 5, 2014

I found another tool:

git config --global filter.tabspace.smudge 'unexpand --tabs=4 --first-only'
git config --global filter.tabspace.clean 'expand --tabs=4 --initial'

Voilà, all my projects use spaces! And everything works.

@dg
Copy link
Contributor

dg commented Sep 5, 2014

Houston, we have a problem. PSR-2 requires, that all PHP files MUST use the Unix LF (linefeed) line ending. But I have Windows. Any ideas?

@pmjones
Copy link

pmjones commented Sep 5, 2014

The cs-fixer takes care of that too, with --fixer=linefeed.

@dg
Copy link
Contributor

dg commented Sep 5, 2014

Great, but I will probably have to stop using Notepad ;)

2014-09-05_17-31-16

@pmjones
Copy link

pmjones commented Sep 5, 2014

heh

@fprochazka
Copy link

@dg LF conversion can be setup by your git client, it will expand LF to windows endings on checkout. And when commiting, it will convert them to LF.

@harikt
Copy link
Author

harikt commented Sep 5, 2014

@dg Thank you.

And now you should apply to fig. We are a community and should not fight for tabs / spaces. And thank you @pmjones .

@harikt
Copy link
Author

harikt commented Sep 5, 2014

@dg I will try how I can help with. But I could not specifically mention a time frame.

Hope you understand.

Thank you.

@pmjones
Copy link

pmjones commented Sep 5, 2014

I agree with @harikt -- if the primary issue has been linefeeds and tabs-vs-spaces, there's no reason I can think of not to apply.

@fprochazka
Copy link

I'm really wondering now, have you just converted @dg to spaces? There is few thousand people/projects that use tabs just because of him :) This is going to be funny.

@dg
Copy link
Contributor

dg commented Sep 5, 2014

Whitespace is something that git can convert and converts on the fly. Unix linefeeds to windows linefeeds and vice versa. Tabs to spaces. Your editor converts them, when you press TAB, it converts it to 4 spaces. So unsignificant whitespace is something absolutely unimportant to me, under my resolution.

But it is neverending theme for holy wars. Something that is invisible, something that is converted on the fly, and so many hours spent in discussing. Probably first world problem :-)

@dg
Copy link
Contributor

dg commented Sep 5, 2014

BTW to force Windows users to use UNIX linefeeds is exactly the same as force owner of diesel cars to pump petrol.

  • Hey, I am using petrol, so you should use petrol too!
  • No, bro, I can't pump petrol, I have diesel engine.
  • Oh, please, think about it. (Why is the cars community so fragmented?)

@harikt
Copy link
Author

harikt commented Sep 5, 2014

@dg may be unix line feeds you can forget .

I don't know whether I really know it or not .

@dg
Copy link
Contributor

dg commented Sep 5, 2014

Wow, this is amazing, PEAR coding standard http://pear.php.net/manual/en/standards.file.php

  • All scripts contributed to PEAR must be stored as ASCII text
  • Use ISO-8859-1 or UTF-8 character encoding (so what? ASCII or UTF-8?)
  • The encoding may be declared using declare(encoding = 'utf-8'); at the top of the file.

I am crying…

@Potherca
Copy link

@dg I've had some fun with that before. PEAR does often seem to be the odd one out 😄

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

No branches or pull requests

5 participants