From ba93a4bfe286ca814084d5482dd7a9a3c91dbf8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2013 12:20:45 +0200 Subject: [PATCH] Fix: Codesniffer --- dev/phpcheckstyle/README | 21 -- dev/phpcheckstyle/phpstandard.cfg.xml | 316 ------------------ dev/phpcheckstyle/phpstandard.dtd | 13 - htdocs/commande/class/commande.class.php | 1 - .../thirdparties_services_expired.modules.php | 5 +- .../fourn/class/fournisseur.product.class.php | 1 + htdocs/opensurvey/adminstuds_preview.php | 6 +- .../class/opensurveysondage.class.php | 2 +- htdocs/opensurvey/fonctions.php | 17 +- htdocs/opensurvey/public/choix_date.php | 8 +- htdocs/opensurvey/public/create_survey.php | 2 +- htdocs/opensurvey/public/exportcsv.php | 11 +- htdocs/public/paybox/paymentko.php | 6 +- htdocs/public/paybox/paymentok.php | 2 +- htdocs/public/paypal/paymentko.php | 2 +- htdocs/public/paypal/paymentok.php | 2 +- test/phpunit/WebservicesInvoicesTest.php | 4 +- test/phpunit/WebservicesOrdersTest.php | 8 +- test/phpunit/WebservicesOtherTest.php | 4 +- test/phpunit/WebservicesThirdpartyTest.php | 4 +- test/phpunit/WebservicesUserTest.php | 4 +- 21 files changed, 45 insertions(+), 394 deletions(-) delete mode 100644 dev/phpcheckstyle/README delete mode 100644 dev/phpcheckstyle/phpstandard.cfg.xml delete mode 100644 dev/phpcheckstyle/phpstandard.dtd diff --git a/dev/phpcheckstyle/README b/dev/phpcheckstyle/README deleted file mode 100644 index 84c6b1bbdc8..00000000000 --- a/dev/phpcheckstyle/README +++ /dev/null @@ -1,21 +0,0 @@ -README (English) --------------------------------- - -This directory contains example of PHPCheckStyle configuration -to use for quality assurance on PHP developpement. - -To run PHPCheckstyle in eclipse, you must: -- install plugin PHP Tools integration http://www.phpsrc.org/eclipse/pti/ -- Unzip PHPCheckStyle archive into a directory. -- Go in Eclipse - Window - Preferences - Dynamic Languages - Validator -Choose External PHP Script, -Set path ro run.php file for localhost -Choose a PHP version, -Set parameter string with - --src %f --config "phpstandard.cfg.xml" --format console -Choose php as Filename extension -Check Print PHP output to console -Then add patern - * %f INFO Line:%n - %m Warning - * %f WARNING Line:%n - %m Warning - * %f ERROR Line:%n - %m Error \ No newline at end of file diff --git a/dev/phpcheckstyle/phpstandard.cfg.xml b/dev/phpcheckstyle/phpstandard.cfg.xml deleted file mode 100644 index 3dd3b314660..00000000000 --- a/dev/phpcheckstyle/phpstandard.cfg.xml +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dev/phpcheckstyle/phpstandard.dtd b/dev/phpcheckstyle/phpstandard.dtd deleted file mode 100644 index bde6e6b2b52..00000000000 --- a/dev/phpcheckstyle/phpstandard.dtd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0270b0327dd..b6e11a64065 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2783,7 +2783,6 @@ class Commande extends CommonOrder * Update value of extrafields on the proposal * * @param User $user Object user that modify - * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ function update_extrafields($user) diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 4b621b705a2..b9d8feccd5c 100755 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -175,11 +175,10 @@ class mailing_thirdparties_services_expired extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param int $filter Filter - * @param string $option Option + * @param string $sql Request * @return int Number of recipients */ - function getNbOfRecipients($sql,$filter=1,$option='') + function getNbOfRecipients($sql='') { $now=dol_now(); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 09843191692..9a86f0e9ee3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -146,6 +146,7 @@ class ProductFournisseur extends Product * @param string $charges costs affering to product * @param float $remise_percent Discount regarding qty (percent) * @param float $remise Discount regarding qty (amount) + * @param int $newnpr Set NPR or not * @return int <0 if KO, >=0 if OK */ function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0) diff --git a/htdocs/opensurvey/adminstuds_preview.php b/htdocs/opensurvey/adminstuds_preview.php index 7e7bb6a6967..54a44d40abb 100755 --- a/htdocs/opensurvey/adminstuds_preview.php +++ b/htdocs/opensurvey/adminstuds_preview.php @@ -202,7 +202,7 @@ if (isset($_POST["ajoutercolonne"]) && ($object->format == "D" || $object->forma //on rajoute la valeur dans les valeurs $datesbase = explode(",",$object->sujet); - $taillebase = sizeof($datesbase); + $taillebase = count($datesbase); //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau if ($nouvelledate < $datesbase[0]) { @@ -210,7 +210,9 @@ if (isset($_POST["ajoutercolonne"]) && ($object->format == "D" || $object->forma } elseif ($nouvelledate > $datesbase[$taillebase-1]) { $cleinsertion = count($datesbase); } else { - for ($i = 0; $i < count($datesbase); $i++) { + $nbdatesbase=count($datesbase); + for ($i = 0; $i < $nbdatesbase; $i++) + { $j = $i + 1; if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) { $cleinsertion = $j; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 7cdfd1e4c7e..0a3f2c571df 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -340,7 +340,7 @@ class Opensurveysondage extends CommonObject * @param string $numsondageadmin Num sondage to delete * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger=0, $numsondageadmin) + function delete($user, $notrigger, $numsondageadmin) { global $conf, $langs; $error=0; diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 6068ca965f1..fc30da7498b 100755 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -120,8 +120,8 @@ function get_server_name() /** * is_error * - * @param unknown_type $cerr - * @return boolean + * @param string $cerr Error value + * @return boolean Error key found or not */ function is_error($cerr) { @@ -147,7 +147,7 @@ function validateEmail($email) { $pattern = '/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD'; - return (bool)preg_match($pattern, $email); + return (bool) preg_match($pattern, $email); } @@ -188,15 +188,16 @@ function getUrlSondage($id, $admin = false) /** - * Generate a random id - * - * @return void + * Generate a random id + * + * @param string $car Char to generate key + * @return void */ function dol_survey_random($car) { $string = ""; $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; - srand((double)microtime()*1000000); + srand((double) microtime()*1000000); for($i=0; $i<$car; $i++) { $string .= $chaine[rand()%strlen($chaine)]; } @@ -229,7 +230,7 @@ function ajouter_sondage($origin) if ($_SESSION["formatsondage"]=="D"||$_SESSION["formatsondage"]=="D+") { //Calcul de la date de fin du sondage - $taille_tableau=sizeof($_SESSION["totalchoixjour"])-1; + $taille_tableau=count($_SESSION["totalchoixjour"])-1; $date_fin=$_SESSION["totalchoixjour"][$taille_tableau]+200000; } diff --git a/htdocs/opensurvey/public/choix_date.php b/htdocs/opensurvey/public/choix_date.php index 72a24357436..59536f1f8e6 100755 --- a/htdocs/opensurvey/public/choix_date.php +++ b/htdocs/opensurvey/public/choix_date.php @@ -257,9 +257,9 @@ if (issetAndNoEmpty('choixjourajout')) { // Si le test est passé, alors on insere la valeur dans la variable de session qui contient les dates if ($journeuf && issetAndNoEmpty('choixjourajout') === true) { - array_push ($_SESSION["totalchoixjour"],mktime (0,0,0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"])); - sort ($_SESSION["totalchoixjour"]); - $cle=array_search (mktime (0,0,0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"]), $_SESSION["totalchoixjour"]); + array_push($_SESSION["totalchoixjour"], dol_mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"])); + sort($_SESSION["totalchoixjour"]); + $cle=array_search(dol_mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"]), $_SESSION["totalchoixjour"]); //On sauvegarde les heures deja entrées for ($i = 0; $i < $cle; $i++) { @@ -540,7 +540,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) && (!issetAndNoEmpty('choixheur //s'il n'y a pas d'erreur et que le bouton de creation est activé, on demande confirmation if (!$erreur && (GETPOST('choixheures') || GETPOST('choixheures_x'))) { - $taille_tableau=sizeof($_SESSION["totalchoixjour"])-1; + $taille_tableau=count($_SESSION["totalchoixjour"])-1; $jour_arret = $_SESSION["totalchoixjour"][$taille_tableau]+200000; $date_fin=dol_print_date($jour_arret, 'dayhourtext'); diff --git a/htdocs/opensurvey/public/create_survey.php b/htdocs/opensurvey/public/create_survey.php index c5af8db0cab..729255a6ca1 100755 --- a/htdocs/opensurvey/public/create_survey.php +++ b/htdocs/opensurvey/public/create_survey.php @@ -162,7 +162,7 @@ print ''."\n"; print '
'."\n"; -#affichage du cochage par défaut +// Check or not $cocheplus=''; if ($_SESSION["canedit"]) $cocheplus="checked"; diff --git a/htdocs/opensurvey/public/exportcsv.php b/htdocs/opensurvey/public/exportcsv.php index b2ee0cc1eea..f933b37a317 100755 --- a/htdocs/opensurvey/public/exportcsv.php +++ b/htdocs/opensurvey/public/exportcsv.php @@ -64,7 +64,6 @@ $now=dol_now(); $nbcolonnes=substr_count($object->sujet,',')+1; $toutsujet=explode(",",$object->sujet); -#$toutsujet=str_replace("°","'",$toutsujet); // affichage des sujets du sondage $input.=$langs->trans("Name").";"; @@ -139,15 +138,15 @@ if ($resql) else dol_print_error($db); -$filesize = strlen( $input ); +$filesize = strlen($input); $filename=$numsondage."_".dol_print_date($now,'%Y%m%d%H%M').".csv"; -header( 'Content-Type: text/csv; charset=utf-8' ); -header( 'Content-Length: '.$filesize ); -header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); -header( 'Cache-Control: max-age=10' ); +header('Content-Type: text/csv; charset=utf-8'); +header('Content-Length: '.$filesize); +header('Content-Disposition: attachment; filename="'.$filename.'"'); +header('Cache-Control: max-age=10'); echo $input; exit; diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index 4db0684005b..19ce36b3b43 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -69,13 +69,13 @@ if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fu $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile( + $mailfile = new CMailFile( 'New subscription payed', $sendto, $from, 'New subscription payed '.$fulltag - ); - + ); + $result=$mailfile->sendfile(); if ($result) { diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index ebd3c834d09..e206556eea1 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -99,7 +99,7 @@ if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fu $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile( + $mailfile = new CMailFile( 'New subscription payed', $sendto, $from, diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index c6fe53ac7b0..a291125253f 100755 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -77,7 +77,7 @@ if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fu $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile( + $mailfile = new CMailFile( 'New subscription payed', $sendto, $from, diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index ca11bcb5422..1241e66b6c8 100755 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -136,7 +136,7 @@ if ($PAYPALTOKEN) $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile( + $mailfile = new CMailFile( 'New subscription payed', $sendto, $from, diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index 65983390cfd..6f04f5320e2 100755 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -118,11 +118,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase /** - * testWSInvoices_xxx + * testWSInvoicesXxx * * @return int */ - public function testWSInvoices_xxx() + public function testWSInvoicesXxx() { global $conf,$user,$langs,$db; $conf=$this->savconf; diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index a4571557a48..750c33fa30a 100755 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -118,11 +118,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase /** - * testWSOrder_xxx + * testWSOrderXxx * * @return int */ - public function testWSOrder_xxx() + public function testWSOrderXxx() { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -178,11 +178,11 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase /** - * testWSOther_GetVersions + * testWSOtherGetVersions * * @return int */ - public function testWSOther_GetVersions() + public function testWSOtherGetVersions() { global $conf,$user,$langs,$db; $conf=$this->savconf; diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index e06477e7de9..e8a8a6bd19c 100755 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -118,11 +118,11 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase /** - * testWSOther_GetVersions + * testWSOtherGetVersions * * @return int */ - public function testWSOther_GetVersions() + public function testWSOtherGetVersions() { global $conf,$user,$langs,$db; $conf=$this->savconf; diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index b28ac8fa2d8..83c7c0ce14d 100755 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -118,11 +118,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase /** - * testWSThirdparty_xxx + * testWSThirdpartyXxx * * @return int */ - public function testWSThirdparty_xxx() + public function testWSThirdpartyXxx() { global $conf,$user,$langs,$db; $conf=$this->savconf; diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 9ef2278015b..832fd1ea4cb 100755 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -118,11 +118,11 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase /** - * testWSUser_xxx + * testWSUserXxx * * @return int */ - public function testWSUser_xxx() + public function testWSUserXxx() { global $conf,$user,$langs,$db; $conf=$this->savconf;