Le 06/08/2012 01:17, Marcos García a écrit :
Hello,

I've checked Dolibarr's code and I've seen that many functions are using integers 1 and 0 as booleans, which actually shouldn't be used because: 1. When checking for True or False, it could be a conflict between 0 and False

This should not happen because when a variable int is used as a boolean, we want 0 to be false and 1 to be true. And this is the defautl behaviour of PHP:
0=false
1=true

We simply should never use boolean but we prefer using integer with rule (0=false, 1 or other = true). When we need a third value (2), we can replace test if ($var) with if ($var==1) or if ($var ==2) according to what we want to do.

That's why we must only use integer.
Boolean is a type very useless and we often need to modify to support a third value, so let's start from scratch with directly int. Even if at the beginning, we need only 2 values.
2. It's not a good practice.

I think this should not be changed immediately but start migrating into it.

Regards,

    *Marcos García*

    [email protected] <mailto:[email protected]>




_______________________________________________
Dolibarr-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev


--
Eldy (Laurent Destailleur).
---------------------------------------------------------------
EMail: [email protected]
Web: http://www.destailleur.fr

Dolibarr (Project leader): http://www.dolibarr.org
To make a donation for Dolibarr project via Paypal: [email protected]
AWStats (Author) : http://awstats.sourceforge.net
To 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 à