eZ Community » Forums » Suggestions » Adopt the PSR-2 coding style in the...
expandshrink

Adopt the PSR-2 coding style in the new eZ Publish 5 kernel

Adopt the PSR-2 coding style in the new eZ Publish 5 kernel

Thursday 12 July 2012 8:19:27 pm - 11 replies

I believe it would be a good idea to change the coding style currently used in eZ Publish and adopt the PSR-2 coding style in eZ Publish 5 & the new public API.

What has especially bothered me in the eZ Publish coding style is the space after the opening parenthesis, and the space before the closing parenthesis, which AFAIK isn't common in the PHP world at all. Except for that particular rule, the current eZ Publish coding style is very close to PSR-2 already.

Thursday 12 July 2012 9:35:43 pm

Good point... 

I see another diff though, regarding to the opening braces after control structures. if i'm not wrong, they MUST be in the following line in ez publish actually, but they MUST be in the same line in PSR-2. I particulary prefer ez publish style in this case happy.gif Emoticon

Btw, do you know any other projects following PSR-2? I'm not a symfony expert at all, but i have looked at their coding guidelines and i can see that there's no need, better said, "you're not allowed" to add spaces for opening / closing parenthesis. But it "prefers" having opening braces for control structures in the following line where they're declared.

imho, if a decision is made in this line, i would follow the symfony guidelines... 

thoughts?

Thursday 12 July 2012 10:11:04 pm

+1 for Kristofs suggestion, especially since this is also symfony2 standard:

"Symfony follows the standards defined in the PSR-0, PSR-1 and PSR-2 documents."

http://symfony.com/doc/current/contributing/code/standards.html

Thursday 12 July 2012 10:19:54 pm

Quote from Patrick Kaiser :

+1 for Kristofs suggestion, especially since this is also symfony2 standard:

"Symfony follows the standards defined in the PSR-0, PSR-1 and PSR-2 documents."

http://symfony.com/doc/current/contributing/code/standards.html

Then it seems i was wrong. i was looking http://trac.symfony-project.org/wiki/HowToContributeToSymfony#CodingStandards

where some samples made me think about the other diff. 

So, waiting for more opinion on this. +1 from here.

Modified on Thursday 12 July 2012 10:20:23 pm by Carlos Revillo

Friday 13 July 2012 7:43:05 am

Quote from Carlos Revillo :

Then it seems i was wrong. i was looking http://trac.symfony-project.org/wiki/HowToContributeToSymfony#CodingStandards

where some samples made me think about the other diff. 

So, waiting for more opinion on this. +1 from here.

Hi Carlos,

The link you are mentioning describes the coding style of Symfony 1. Patrick pointed to the right one, for Symfony 2. You were right though about the opening braces of control structures, eZ Publish currently does this different than PSR-2.

Modified on Friday 13 July 2012 7:43:49 am by Kristof Coomans

Friday 13 July 2012 7:57:08 am

Quote from Carlos Revillo :

Btw, do you know any other projects following PSR-2?

Zend Framework 2 seems to be adopting PSR-1 and 2 as well, if you look at the pull requests on their github repo (among them https://github.com/zendframework/zf2/pull/1875 and https://github.com/zendframework/zf2/pull/1876). The project lead of Zend Framework is a voting member of the PHP FIG. I suppose other projects of people involved in the FIG will adopt it soon or later as well. For the full list, check https://github.com/php-fig/fig-standards. And who is there at number 18? Andre Romcke: eZ Publish.

Friday 13 July 2012 9:43:06 am

Quote from Kristof Coomans :
Quote from Carlos Revillo :

The project lead of Zend Framework is a voting member of the PHP FIG. I suppose other projects of people involved in the FIG will adopt it soon or later as well. For the full list, check https://github.com/php-fig/fig-standards. And who is there at number 18? Andre Romcke: eZ Publish.

I see... thanks for the info. looks ez systems should consider this happy.gif Emoticon

Friday 13 July 2012 4:46:13 pm

For reference we voted 0 on PSR-2, for the reasons Carlos mentioned in his first comment.

So currently we haven't planed to use it, but PSR-1 on the other hand is straight forward. But as we are using Symfony and if the Community wants this, then we will of course re consider and see if we can survive living in a world with inconsistent bracket use.. happy.gif Emoticon

Wednesday 20 August 2014 10:48:55 am

+1 for Kristofs suggestion, especially since this is also symfony2 standard. php-cs-fixer could be used to resolve most stuff automatically.

Wednesday 20 August 2014 12:08:22 pm

Hi,

 

good old thread, after a bit back and forwards we internally agreed that we will do this, but we'll do it after 5.4 so this is a eZ Studio and eZ Platform thing, and eZ Publish 5.x is left as is for easier maintenance.

Sounds ok?

Modified on Wednesday 20 August 2014 12:09:11 pm by André R

Wednesday 20 August 2014 1:51:17 pm

That's good news!

Thursday 28 August 2014 11:20:56 pm

Hello,

I added a note about this upcoming change in eZpedia:

http://www.ezpedia.org/new_stack/code_standards#eztoc1280234_0_2

Cheers,
Heath

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from