Fix with php-cs-fixer

This commit is contained in:
Laurent Destailleur 2023-12-04 11:21:01 +01:00
parent cbd4d75c22
commit 881e32f03a
15 changed files with 56 additions and 40 deletions

1
.gitignore vendored
View File

@ -67,3 +67,4 @@ doc/install.lock
/build/phpstan/bootstrap_custom.php
phpstan_custom.neon
/.php-cs-fixer.cache
/.php_cs.cache

View File

@ -47,7 +47,7 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
define('GEN_NUMBER_FACTURE', $argv[1] ?? 1);
$year = 2016;
$dates = array (mktime(12, 0, 0, 1, 3, $year),
$dates = array(mktime(12, 0, 0, 1, 3, $year),
mktime(12, 0, 0, 1, 9, $year),
mktime(12, 0, 0, 2, 13, $year),
mktime(12, 0, 0, 2, 23, $year),
@ -168,7 +168,8 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) {
$result=$object->validate($fuser);
if ($result) {
print " OK with ref ".$object->ref."\n";;
print " OK with ref ".$object->ref."\n";
;
} else {
dol_print_error($db, $object->error);
}

View File

@ -53,7 +53,7 @@ require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
define('GEN_NUMBER_COMMANDE', $argv[1] ?? 10);
$year = 2016;
$dates = array (mktime(12, 0, 0, 1, 3, $year),
$dates = array(mktime(12, 0, 0, 1, 3, $year),
mktime(12, 0, 0, 1, 9, $year),
mktime(12, 0, 0, 2, 13, $year),
mktime(12, 0, 0, 2, 23, $year),

View File

@ -64,18 +64,24 @@ $user->getrights();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
$resql=$db->query($sql);
if ($resql) {
$num = $db->num_rows($resql); $i = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++;
$row = $db->fetch_row($resql);
$productsid[$i] = $row[0];
$i++;
}
}
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
$resql=$db->query($sql);
if ($resql) {
$num = $db->num_rows($resql); $i = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++;
$row = $db->fetch_row($resql);
$societesid[$i] = $row[0];
$i++;
}
} else {
print "err";
@ -84,9 +90,12 @@ if ($resql) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
$resql=$db->query($sql);
if ($resql) {
$num = $db->num_rows($resql); $i = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++;
$row = $db->fetch_row($resql);
$commandesid[$i] = $row[0];
$i++;
}
} else {
print "err";
@ -99,7 +108,7 @@ for ($s = 0; $s < GEN_NUMBER_PRODUIT; $s++) {
$produit = new Product($db);
$produit->type = mt_rand(0, 1);
$produit->status = 1;
$produit->ref = ($produit->type?'S':'P').time().$s;
$produit->ref = ($produit->type ? 'S' : 'P').time().$s;
$produit->label = 'Label '.time().$s;
$produit->description = 'Description '.time().$s;
$produit->price = mt_rand(1, 999.99);

View File

@ -49,7 +49,7 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
define('GEN_NUMBER_PROPAL', $argv[1] ?? 10);
$year = 2016;
$dates = array (mktime(12, 0, 0, 1, 3, $year),
$dates = array(mktime(12, 0, 0, 1, 3, $year),
mktime(12, 0, 0, 1, 9, $year),
mktime(12, 0, 0, 2, 13, $year),
mktime(12, 0, 0, 2, 23, $year),

View File

@ -67,7 +67,8 @@ $user->getrights();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
$resql=$db->query($sql);
if ($resql) {
$num = $db->num_rows($resql); $i = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql);
$productsid[$i] = $row[0];
@ -78,7 +79,8 @@ if ($resql) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
$resql=$db->query($sql);
if ($resql) {
$num = $db->num_rows($resql); $i = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql);
$societesid[$i] = $row[0];
@ -91,7 +93,8 @@ if ($resql) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
$resql=$db->query($sql);
if ($resql) {
$num = $db->num_rows($resql); $i = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql);
$commandesid[$i] = $row[0];
@ -117,7 +120,8 @@ for ($s = 0; $s < GEN_NUMBER_SOCIETE; $s++) {
$soc->country_id=1;
$soc->country_code='FR';
// Un client sur 3 a une remise de 5%
$user_remise=mt_rand(1, 3); if ($user_remise==3) {
$user_remise=mt_rand(1, 3);
if ($user_remise==3) {
$soc->remise_percent=5;
}
print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n";

View File

@ -62,9 +62,9 @@ dol_syslog($script_file." launched with arg ".implode(',', $argv));
$mode = $argv[1];
$filepath = $argv[2];
$filepatherr = $filepath.'.err';
$defaultlang = empty($argv[3])?'en_US':$argv[3];
$startlinenb = empty($argv[4])?1:$argv[4];
$endlinenb = empty($argv[5])?0:$argv[5];
$defaultlang = empty($argv[3]) ? 'en_US' : $argv[3];
$startlinenb = empty($argv[4]) ? 1 : $argv[4];
$endlinenb = empty($argv[5]) ? 0 : $argv[5];
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";

View File

@ -63,8 +63,8 @@ $mode = $argv[1];
$filepath = $argv[2];
$filepatherr = $filepath.'.err';
//$defaultlang = empty($argv[3])?'en_US':$argv[3];
$startlinenb = empty($argv[3])?1:$argv[3];
$endlinenb = empty($argv[4])?0:$argv[4];
$startlinenb = empty($argv[3]) ? 1 : $argv[3];
$endlinenb = empty($argv[4]) ? 0 : $argv[4];
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
@ -128,8 +128,8 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
$object->client = $fields[7];
$object->fournisseur = $fields[8];
$object->name = $fields[13]?trim($fields[13]):$fields[0];
$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
$object->name = $fields[13] ? trim($fields[13]) : $fields[0];
$object->name_alias = $fields[0]!=$fields[13] ? trim($fields[0]) : '';
$object->address = trim($fields[14]);
$object->zip = trim($fields[15]);

View File

@ -63,8 +63,8 @@ $mode = $argv[1];
$filepath = $argv[2];
$filepatherr = $filepath.'.err';
//$defaultlang = empty($argv[3])?'en_US':$argv[3];
$startlinenb = empty($argv[3])?1:$argv[3];
$endlinenb = empty($argv[4])?0:$argv[4];
$startlinenb = empty($argv[3]) ? 1 : $argv[3];
$endlinenb = empty($argv[4]) ? 0 : $argv[4];
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";

View File

@ -62,7 +62,6 @@ class UserRightsToFunction extends AbstractRector
*/
public function refactor(Node $node)
{
if ($node instanceof Node\Stmt\ClassMethod) {
$excludeMethods = ['getrights', 'hasRight'];
/** @var \PHPStan\Analyser\MutatingScope $scope */

View File

@ -1,4 +1,5 @@
<?php
//============================================================+
// File name : example_016.php
// Begin : 2008-03-04

View File

@ -1,4 +1,5 @@
<?php
// This source file must be UTF-8 encoded
/*
$filename='filewithé';

View File

@ -74,7 +74,6 @@ class autoTranslator
*/
private function parseRefLangTranslationFiles()
{
$files = $this->getTranslationFilesArray($this->_refLang);
$counter = 1;
foreach ($files as $file) {
@ -276,7 +275,7 @@ class autoTranslator
private function getLineValue($line)
{
$arraykey = explode('=', $line, 2);
return trim(isset($arraykey[1])?$arraykey[1]:'');
return trim(isset($arraykey[1]) ? $arraykey[1] : '');
}
/**
@ -334,8 +333,8 @@ class autoTranslator
//print "Url to translate: ".$url."\n";
if (! function_exists("curl_init")) {
print "Error, your PHP does not support curl functions.\n";
die();
print "Error, your PHP does not support curl functions.\n";
die();
}
$ch = curl_init();

View File

@ -210,7 +210,8 @@ foreach ($dups as $string => $pages) {
$inadmin=0;
foreach ($pages as $file => $lines) {
if ($file == 'main.lang') {
$inmain=1; $inadmin=0;
$inmain=1;
$inadmin=0;
}
if ($file == 'admin.lang' && ! $inmain) {
$inadmin=1;
@ -568,16 +569,16 @@ if ((!empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($ar
if (empty($unused)) {
print "No string not used found.\n";
} else {
$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
$filetosave='/tmp/'.($argv[2] ? $argv[2] : "").'notused.lang';
print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
file_put_contents($filetosave, implode("", $unused));
print "To remove from original file, run command :\n";
if (($argv[2]?$argv[2]:"")) {
print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
if (($argv[2] ? $argv[2] : "")) {
print 'cd htdocs/langs/en_US; mv '.($argv[2] ? $argv[2] : "")." ".($argv[2] ? $argv[2] : "").".tmp; ";
}
print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2]?$argv[2]:"");
if (($argv[2]?$argv[2]:"")) {
print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
print "diff ".($argv[2] ? $argv[2] : "").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2] ? $argv[2] : "");
if (($argv[2] ? $argv[2] : "")) {
print "; rm ".($argv[2] ? $argv[2] : "").".tmp;\n";
}
}
}

View File

@ -58,10 +58,10 @@ $rc = 0;
// Get and check arguments
$lPrimary = isset($argv[1])?$argv[1]:'';
$lSecondary = isset($argv[2])?$argv[2]:'';
$lPrimary = isset($argv[1]) ? $argv[1] : '';
$lSecondary = isset($argv[2]) ? $argv[2] : '';
$lEnglish = 'en_US';
$filesToProcess = isset($argv[3])?$argv[3]:'';
$filesToProcess = isset($argv[3]) ? $argv[3] : '';
if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess)) {
$rc = 1;
@ -308,7 +308,7 @@ foreach ($filesToProcess as $fileToProcess) {
|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)
) {
//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
fwrite($oh, $key."=".(empty($aSecondary[$key]) ? $aPrimary[$key] : $aSecondary[$key])."\n");
}
}
if (! feof($handle)) {