You're right. You should have

if (! empty($conf->categorie->enabled) ...)

I introduce a bad code because i did a cut and paste code from other file
of dolibarr done by a developer that did not follow rule. So my cut and
paste was wrong too. But i confirm the good coding is

if (! empty($conf->categorie->enabled) ...)

and not

if (! empty( $conf->categorie->enabled ) ...)

without the spaces.

I will not change for the moment rule to allow tabs because I had to manage
too many problem with full spaces and it was a waste of time. Changing the
rule just magically solve all problem i experienced. May be we will change
on day, but this rule is not priority, so i prefer to keep it and focus
efforts on all other rules.





2015-06-28 21:33 GMT+02:00 Yannick Warnier <[email protected]>:

> There are still a few issues I think might be beneficial to fix on the
> wiki. For example:
>
> $var1=1;$var2=1;$var3=1;
>
> Because PSR-2 says "There MUST NOT be more than one statement per line."
>
> Also, in PSR-2 section 4.6, it says "When making a method or function
> call, there MUST NOT be a space between the method or function name and
> the opening parenthesis, there MUST NOT be a space after the opening
> parenthesis, and there MUST NOT be a space before the closing
> parenthesis. In the argument list, there MUST NOT be a space before each
> comma, and there MUST be one space after each comma."
>
> I see that in your latest commit, Eldy,
>
> https://github.com/Dolibarr/dolibarr/commit/ce6039f7f644657e3215385fc1698ecde114919f
> you use stuff like:
>
> if (! empty( $conf->categorie->enabled ) ...)
>
> whereas, clearly, following PSR-2 and having no exception for this case
> on the wiki, you should use:
>
> if (! empty($conf->categorie->enabled) ...)
>
> (and maybe no space between "!" and "empty", but there's no specific
> rule about that).
>
>
> Also, I know I'm not going to change your conventions, but I must insist
> a little on the 4-spaces thing instead of tabs.
> I'm not seeing this as an issue for any editor, but PSR-2 is strict on
> this: "Code MUST use 4 spaces for indenting, not tabs.", and adopting
> part of PSR-2 is a bit weird (and certainly introduces more complexity
> for new developers joining). Going with exceptions now will only delay
> the full adoption of PSR-2, and will require a lot of additional work
> afterwards if, one day, you decide to go for 4 tabs to respect PSR-2.
> Just saying... :-)
>
> Cheers,
>
> Yannick
>
>
> Le dimanche 28 juin 2015 à 11:04 +0200, Laurent Destailleur (aka Eldy) a
> écrit :
> > Hi Yannick.
> >
> >
> > Thanks for your feedback. I updated the
> > page http://wiki.dolibarr.org/index.php/Language_and_development_rules
> so things should be easier to understand and you should find answer to all
> your questions.
> >
> > 2015-06-28 3:00 GMT+02:00 Yannick Warnier <[email protected]>:
> >         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.
> >
> >
> >
> >
> >         _______________________________________________
> >         Dolibarr-dev mailing list
> >         [email protected]
> >         https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
> >
> >
> >
> >
> > --
> > EMail: [email protected]
> > Web: http://www.destailleur.fr
> >
> ------------------------------------------------------------------------------------
> >
> > Google+: https://plus.google.com/+LaurentDestailleur/
> > Facebook: https://www.facebook.com/Destailleur.Laurent
> > Twitter: http://www.twitter.com/eldy10
> >
> ------------------------------------------------------------------------------------
> > * Dolibarr (Project leader): http://www.dolibarr.org (make a donation
> > for Dolibarr project via Paypal: [email protected])
> > * AWStats (Author) : http://awstats.sourceforge.net (make a donation
> > for AWStats project via Paypal: [email protected])
> > * AWBot (Author) : http://awbot.sourceforge.net
> >
> > * CVSChangeLogBuilder (Author) : http://cvschangelogb.sourceforge.net
> >
> >
> >
> >
> >
> > _______________________________________________
> > Dolibarr-dev mailing list
> > [email protected]
> > https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
>
>
>
> _______________________________________________
> Dolibarr-dev mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
>



-- 
EMail: [email protected]
Web: http://www.destailleur.fr
------------------------------------------------------------------------------------
Google+: https://plus.google.com/+LaurentDestailleur/
Facebook: https://www.facebook.com/Destailleur.Laurent
Twitter: http://www.twitter.com/eldy10
------------------------------------------------------------------------------------
* Dolibarr (Project leader): http://www.dolibarr.org (make a donation for
Dolibarr project via Paypal: [email protected])
* AWStats (Author) : http://awstats.sourceforge.net (make a donation for
AWStats project via Paypal: [email protected])
* AWBot (Author) : http://awbot.sourceforge.net
* CVSChangeLogBuilder (Author) : http://cvschangelogb.sourceforge.net
_______________________________________________
Dolibarr-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev

Répondre à