clean code (#35534)
* clean code * clean code * clean code * clean code * clean code
This commit is contained in:
parent
7fb7d38ffc
commit
a8b4ae7dfb
7 changed files with 23 additions and 123 deletions
|
|
@ -9474,60 +9474,6 @@ parameters:
|
|||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorbooth.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function property_exists\(\) with \$this\(ConferenceOrBoothAttendee\) and ''fk_soc'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function property_exists\(\) with ConferenceOrBoothAttendee and ''date_creation'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function property_exists\(\) with ConferenceOrBoothAttendee and ''date_modification'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function property_exists\(\) with ConferenceOrBoothAttendee and ''ref'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function property_exists\(\) with ConferenceOrBoothAttendee and ''status'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Left side of && is always false\.$#'
|
||||
identifier: booleanAnd.leftAlwaysFalse
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Negated boolean expression is always true\.$#'
|
||||
identifier: booleanNot.alwaysTrue
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Property ConferenceOrBoothAttendee\:\:\$lastname \(string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Property ConferenceOrBoothAttendee\:\:\$status \(int\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 1
|
||||
path: ../../../htdocs/eventorganization/class/conferenceorboothattendee.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function method_exists\(\) with Project and ''fetchComments'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
|
|
|
|||
|
|
@ -682,12 +682,12 @@ abstract class CommonObject
|
|||
public $name;
|
||||
|
||||
/**
|
||||
* @var string The lastname
|
||||
* @var ?string The lastname
|
||||
*/
|
||||
public $lastname;
|
||||
|
||||
/**
|
||||
* @var string The firstname
|
||||
* @var ?string The firstname
|
||||
*/
|
||||
public $firstname;
|
||||
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ class ConferenceOrBooth extends ActionComm
|
|||
if ($key == 't.id' || $key == 't.fk_project' || $key == 't.fk_soc' || $key == 't.fk_action') {
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value);
|
||||
} elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'";
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate((int) $value)."'";
|
||||
} elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value; // deprecated
|
||||
} elseif (strpos($value, '%') === false) {
|
||||
|
|
|
|||
|
|
@ -134,11 +134,11 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
*/
|
||||
public $email;
|
||||
/**
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
public $firstname;
|
||||
/**
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
public $lastname;
|
||||
/**
|
||||
|
|
@ -161,14 +161,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
* @var string|float (Price)
|
||||
*/
|
||||
public $amount;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $note_public;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $note_private;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
@ -182,15 +175,16 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
*/
|
||||
public $last_main_doc;
|
||||
/**
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
public $import_key;
|
||||
/**
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
public $model_pdf;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var ?int
|
||||
*/
|
||||
public $status;
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
|
@ -350,20 +344,11 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
unset($object->import_key);
|
||||
|
||||
// Clear fields
|
||||
if (property_exists($object, 'ref')) {
|
||||
// @phan-suppress-next-line PhanTypeInvalidDimOffset
|
||||
$object->ref = empty($this->fields['ref']['default']) ? "(PROV)" : $this->fields['ref']['default'];
|
||||
}
|
||||
if (property_exists($object, 'status')) {
|
||||
$object->status = self::STATUS_DRAFT;
|
||||
}
|
||||
if (property_exists($object, 'date_creation')) {
|
||||
$object->date_creation = dol_now();
|
||||
}
|
||||
if (property_exists($object, 'date_modification')) {
|
||||
$object->date_modification = null;
|
||||
}
|
||||
// ...
|
||||
$object->ref = "(PROV)";
|
||||
$object->status = self::STATUS_DRAFT;
|
||||
$object->date_creation = dol_now();
|
||||
$object->date_modification = null;
|
||||
|
||||
// Clear extrafields that are unique
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
$extrafields->fetch_name_optionals_label($this->table_element);
|
||||
|
|
@ -397,7 +382,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
|
||||
if (!$error) {
|
||||
// copy external contacts if same company
|
||||
if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
|
||||
if (!empty($this->fk_soc) && $this->fk_soc == $object->socid) {
|
||||
if ($this->copy_linked_contact($object, 'external') < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
|
@ -483,7 +468,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
if ($key == 't.rowid' || $key == 't.fk_soc' || $key == 't.fk_project' || $key == 't.fk_actioncomm') {
|
||||
$sqlwhere[] = $this->db->sanitize($key).' = '.((int) $value);
|
||||
} elseif (!empty($this->fields[$key]) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'";
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate((int) $value)."'";
|
||||
} elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
} elseif (strpos($value, '%') === false) {
|
||||
|
|
@ -612,7 +597,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
|
||||
// Define new ref
|
||||
$num = (string) $this->ref;
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $num) || empty($num))) { // empty should not happened, but when it occurs, the test saves life
|
||||
if (preg_match('/^[\(]?PROV/i', $num) || empty($num)) { // empty should not happened, but when it occurs, the test saves life
|
||||
$num = $this->getNextNumRef();
|
||||
}
|
||||
|
||||
|
|
@ -1096,7 +1081,6 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
global $conf, $langs;
|
||||
|
||||
$result = 0;
|
||||
$includedocgeneration = 0;
|
||||
|
||||
$langs->load("eventorganization@eventorganization");
|
||||
|
||||
|
|
@ -1112,43 +1096,13 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
|
||||
$modelpath = "core/modules/eventorganization/doc/";
|
||||
|
||||
if ($includedocgeneration && !empty($modele)) {
|
||||
if (!empty($modele)) {
|
||||
$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action executed by scheduler
|
||||
* CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
|
||||
* Use public function doScheduledJob($param1, $param2, ...) to get parameters
|
||||
*
|
||||
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
|
||||
*/
|
||||
public function doScheduledJob()
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
|
||||
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error = '';
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// ...
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to replace a thirdparty id with another one.
|
||||
*
|
||||
|
|
@ -1185,7 +1139,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
|
||||
$ret = '';
|
||||
|
||||
$ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
|
||||
$ret .= dolGetFirstLastname((string) $firstname, (string) $lastname, $nameorder);
|
||||
|
||||
return dol_trunc($ret, $maxlen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -708,7 +708,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $user->hasRight('eventorganization', 'conferenceorboothattendee', 'read'); // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->hasRight('eventorganization', 'conferenceorboothattendee', 'write'); // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('eventorganization:ConferenceOrBoothAttendee', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
||||
print $formfile->showdocuments('eventorganization:ConferenceOrBoothAttendee', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, (string) $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
||||
}
|
||||
|
||||
// Show links to link elements
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ class RecruitmentCandidature extends CommonObject
|
|||
|
||||
$ret = '';
|
||||
|
||||
$ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
|
||||
$ret .= dolGetFirstLastname((string) $firstname, (string) $lastname, $nameorder);
|
||||
|
||||
return dol_trunc($ret, $maxlen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ class UserGroup extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
$ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
|
||||
$ret .= dolGetFirstLastname((string) $firstname, (string) $lastname, $nameorder);
|
||||
|
||||
return dol_trunc($ret, $maxlen);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue