Jump to content
Jerome Nadaud

PSR2 development norm for PrestaShop

PSR2 development norm for PrestaShop  

52 members have voted

  1. 1. Are you in favour of changing PrestaShop development norm to PSR2+ dev norm?



Recommended Posts

Hi,

 

We are discussing the possibility of changing PrestaShop development norm to PSR2+. This would affect developers of the Community (in a good way, we think), so if you do contribute to PrestaShop's ecosystem with PR's, modules, themes, etc... your vote is important!

 

Thank you.

 

Jérôme.

  • Like 4

Share this post


Link to post
Share on other sites

To make sure that everyone understands what this means: PSR-2 is a coding style guide standard published by the PHP Framework Interoperability Group (or PHP-FIG), an informal group of representatives from major PHP projects, which offers a place to "talk about the commonalities between our projects and find ways we can work together" (see the FAQ). The group issues a series of standards (PSRs, or PHP Standard Recommendation) on how to best build a PHP project.

 

PSR-2 establishes a coding style guide. It builds upon PSR-1's "Basic Coding standard", which PrestaShop follows closely (but not entirely) thanks to its Coding Standard.

 

Using PSR-2 (and thus PSR-1) means that we will slightly change our Coding Standard to follow PHP-FIG's norm. The code behavior itself will not change much: mostly, only the way the code is written will change, and since it's already close to those standards, the impact should be minimal. Still, choosing the follow PSR-2 will imply some code reformatting here and there, and will make sure that our open-source code will be more likely to be used by other PSR-2-using projects!

 

If you think this is a bad idea, please comment!

  • Like 5

Share this post


Link to post
Share on other sites

I don't think it's fondamentally a bad idea to change coding style.

 

But coding style isn't the problem when you start reading Prestashop code.

There is other areas where spending time will improve developer experience.

  • Like 5

Share this post


Link to post
Share on other sites

But coding style isn't the problem when you start reading Prestashop code.

There is other areas where spending time will improve developer experience.

 

Choosing to follow PSR-2 from now will certainly not detract our developers from the time they spend impriving the code and adding features (see the Core Weekly for a proof of that). If anything, it will push them to review code that hasn't changed for a long time because it had no notable issue, and will thus give fresh pair of eyes on those lines of code. So in the end, we might even see more bugs fixed while doing this :)

Share this post


Link to post
Share on other sites

 

If anything, it will push them to review code that hasn't changed for a long time because it had no notable issue, and will thus give fresh pair of eyes on those lines of code. So in the end, we might even see more bugs fixed while doing this :)

 

 

There is no need to understand code when you review coding style, so I doubt there will be much improvement / refactoring. :ph34r:

 

But if the objective is :

 

and will make sure that our open-source code will be more likely to be used by other PSR-2-using projects!

 

then coding style is not very relevant.

Prestashop (even parts of it) is hard to interact with / integrate in other projects.  Because it's monolithic, slow, hard to debug, not documented, and some parts are poorly designed.

 

 

Note: I have nothing against PSR-2, it will add some consistency in code, and it will be very usefull the day prestashop will include other components from the community (PSR-3 Loggers, PSR-4 autoloading).

I just see it as a "Nice to Have".

Edited by hpar (see edit history)
  • Like 4

Share this post


Link to post
Share on other sites

If I understood it correctly. All ifs / functions etc must end with }.

Meaning all one line ifs should be changed to using braces { }

 

That would re-factor alot of files...

 

But i'm all for this.

  • Like 1

Share this post


Link to post
Share on other sites

Please cancel your own coding standard and use a common one.

 

If anything, it will push them to review code that hasn't changed for a long time because it had no notable issue, and will thus give fresh pair of eyes on those lines of code. So in the end, we might even see more bugs fixed while doing this :)

 

Take care that refactoring the code may fix some bugs but also introduce new ones :)

Have you all the test cases to check you don't have regressions ?

  • Like 1

Share this post


Link to post
Share on other sites

It's always a good idea to improve coding standards on an open source project, but it's far to be a priority right now IMO.

 

+ what about modules validation ?

  • Like 1

Share this post


Link to post
Share on other sites

This would affect developers of the Community (in a good way, we think), so if you do contribute to PrestaShop's ecosystem with PR's, modules, themes, etc... your vote is important!

 

.

In general I am in, but this also means that you will force to rewrite all modules for the second time, because of the great Validator.

 

Nice!!!!

 

At least some competing developers will leave.

  • Like 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More