as Marcos says, for some cases it may be useful in differentiating 0 and false, false as a state and a 0 value, it could avoid mistakes.
Le 06/08/12 01:44, Laurent Destailleur (eldy) a écrit : > 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 Cordialement, -- Régis Houssin --------------------------------------------------------- Cap-Networks Cidex 1130 34, route de Gigny 71240 MARNAY FRANCE VoIP: +33 1 83 62 40 03 GSM: +33 6 33 02 07 97 Web: http://www.cap-networks.com/ Email: [email protected] Dolibarr developer: [email protected] Web Portal: http://www.dolibarr.fr/ SaaS offers: http://www.dolibox.fr/ Shop: http://www.dolistore.com/ Development platform: https://doliforge.org/ ---------------------------------------------------------
_______________________________________________ Dolibarr-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
