From 31ba277da708f99d33b3476c8997a74398b206f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 26 Apr 2020 23:18:09 +0200 Subject: [PATCH] Fix phpcs --- .../compta/paiement/class/cpaiement.class.php | 2 +- htdocs/core/class/smtps.class.php | 19 +++++-------------- htdocs/core/db/sqlite3.class.php | 2 +- htdocs/expensereport/card.php | 4 ++-- test/phpunit/AdherentTest.php | 10 +++++----- test/phpunit/FilesLibTest.php | 2 +- 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 5b66dbec15e..d1cd1f0015b 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -185,7 +185,7 @@ class Cpaiement $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (null !== $ref) { $sql .= ' WHERE t.entity IN ('.getEntity('c_paiement').')'; - $sql .= ' AND t.code = '.'\''.$ref.'\''; + $sql .= " AND t.code = '".$this->db->escape($ref)."'"; } else { $sql .= ' WHERE t.id = '.$id; } diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index f6bc31c2f53..51e375c5279 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1534,34 +1534,25 @@ class SMTPs $content .= "--".$this->_getBoundary('alternative')."\r\n"; } - $content .= 'Content-Type: '.$_content['mimeType'].'; ' - // . 'charset="' . $this->getCharSet() . '"'; - . 'charset='.$this->getCharSet().''; + $content .= 'Content-Type: '.$_content['mimeType'].'; charset='.$this->getCharSet(); - // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; $content .= "\r\n"; - // $content .= 'Content-Transfer-Encoding: '; - // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); - // $content .= "\r\n" - // . 'Content-Disposition: inline' . "\r\n" - // . 'Content-Description: ' . $type . ' message' . "\r\n"; - if ($this->getMD5flag()) - $content .= 'Content-MD5: '.$_content['md5']."\r\n"; + if ($this->getMD5flag()) { + $content .= 'Content-MD5: '.$_content['md5']."\r\n"; + } $content .= "\r\n".$_content['data']."\r\n"; if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part { - $content .= "--".$this->_getBoundary('alternative')."--"."\r\n"; + $content .= "--".$this->_getBoundary('alternative')."--\r\n"; } $content .= "\r\n"; } } - // Close message boundries - // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; $content .= "--".$this->_getBoundary('mixed').'--'."\r\n"; } diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index ba8f8eff3e9..2d24c232797 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -1325,7 +1325,7 @@ class DoliDBSqlite3 extends DoliDB if ($this->db) { $newname = preg_replace('/_/', '', $name); - $localname = __CLASS__.'::'.'db'.$newname; + $localname = __CLASS__.'::db'.$newname; $reflectClass = new ReflectionClass(__CLASS__); $reflectFunction = $reflectClass->getMethod('db'.$newname); if ($arg_count < 0) { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index fd582ac0a1e..2a0f804b196 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2330,7 +2330,7 @@ else print ''; if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - print '   -   '.''.$langs->trans("AttachTheNewLineToTheDocument"); + print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; } @@ -2478,7 +2478,7 @@ else print ''; if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - print '   -   '.''.$langs->trans("AttachTheNewLineToTheDocument"); + print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; } diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index c78bc6542bb..89e78b32bd9 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -325,13 +325,13 @@ class AdherentTest extends PHPUnit\Framework\TestCase $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 0; // Force setup for firstname+lastname - $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'. - '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__'; + $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'; + $template .= '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__'; // If option to store clear password has been set, we get 'dolibspec' into PASSWORD field. - $expected = ',New firstname,New name,New firstname New name,'. - 'New company label,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->birth, 'day').',,'. - 'newlogin'; + $expected = ',New firstname,New name,New firstname New name,'; + $expected .= 'New company label,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->birth, 'day').',,'; + $expected .= 'newlogin'; $result = $localobject->makeSubstitution($template); print __METHOD__." result=".$result."\n"; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 776e783a6b0..fb3ce8f5814 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -336,7 +336,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1, $result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv'.')'); // Should be 1 + $this->assertGreaterThanOrEqual(1, $result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv)'); // Should be 1 // Again to test with overwriting=0 $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 0);