dolibarr-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dolibarr-dev] Coding conventions & PSR


From: Yannick Warnier
Subject: [Dolibarr-dev] Coding conventions & PSR
Date: Sat, 27 Jun 2015 20:00:08 -0500

Hi guys,

First of all, just a short presentation: my name is Yannick Warnier, I
worked as one of the first 20 Dolibarr developers or so (copyright
notices in VAT reports say it was between 2006 and 2007). I stopped
developing mainly because I was too busy with my own project (Dokeos and
then Chamilo). I speak and write fluently French, English and Spanish.
I'm using English to increase my chances to be understood.

At our company, we've been working with Dolibarr 2.2 for years and have
recently found a little time to work on an upgrade to 3.7 (or 3.8 to
come).

As part of that work, I'm reviewing some of the work I had done back
then, and I am mostly interested in htdocs/compta/tva/quadri_detail.php

I saw that it was modified considerably (definitely improved) and that
some of the functions I wrote were slightly changed and moved to
core/lib/tax.lib.php (thanks for that).

This being said, I want to re-create my original report, because the new
version removed some dates and other info we needed for our VAT report
in Belgium.

As such, I am looking at how to modify a copy of this script, and I'm
faced with a series of questions/comments I do not know how to answer,
and after visiting
http://wiki.dolibarr.org/index.php/Language_and_development_rules I am
still a bit unsure, so here they are:

1) It says you use PSR-2, but the code is filled with non-conformant
PSR-2 (which includes PSR-1). So my question is:
Should I consider PSR-2 is the norm and switch everything I see that is
non-conformant to PSR-2, or should I leave it like that?
And should my code be PSR-2 conformant or should I try to integrate to
what is there at the moment?

2) One line says: "Do not use PHP_SELF. Use instead
$_SERVER["PHP_SELF"]."
I was wondering if you were considering that $_SERVER is something
hackable, and as such should be filtered... (so using
$_SERVER['PHP_SELF'] unfiltered is definitely an issue)

3) It says "When several variables must be initialized with same value,
you must use several lines", but the example below is on a single
line...

4) About PSR-2 exceptions:

4a) you mention 2, and then there are 4 that are not all real exceptions

4b) you indicate that *you* accept more than 80 chars per line.
Actually, PSR-2 mention you *should* try lower than 80, but you *can* go
up to 120.

4c) you mention that you don't replace the tabs with spaces because that
drives editors crazy... I'm not sure about the editors you use, but I
use VIM, Eclipse and PHPStorm, and the crazyness only happens with tabs,
not spaces. Furthermore, I see that many files have either 4 spaces *or*
tabs, so I don't really understand what I should respect...
In any case, if that's worth anything, PSR-2 should be used strictly, so
4 spaces is a good idea and it's easy to implement (most editors offer a
tabs-replacement-with-spaces feature that is safe to implement)

The rest is pretty clear to me.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]