From d681876aa49bc63993923a1b0626de7c0114b56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Sep 2023 13:56:55 +0200 Subject: [PATCH 1/3] phpstan ::error file=htdocs/core/class/cunits.class.php,line=75,col=0::Access to an undefined property CUnits::$libelle. ::error file=htdocs/core/class/cunits.class.php,line=302,col=0::Access to an undefined property CUnits::$libelle. --- htdocs/core/class/cunits.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index b08efd1bd07..80b96f2c874 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -35,6 +35,13 @@ class CUnits extends CommonDict //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored + /** + * @var string label + * @deprecated + * @see $label + */ + public $libelle; + public $sortorder; public $short_label; public $unit_type; From 6483704e78b4bb212dae411d736f31d7728d9324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Sep 2023 14:04:23 +0200 Subject: [PATCH 2/3] clean code phpstan ::error file=htdocs/core/class/timespent.class.php,line=1004,col=0::Instantiated class TimeSpentLine not found. --- htdocs/core/class/timespent.class.php | 62 +-------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index 669a6929988..c801f342a2d 100755 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -153,43 +153,6 @@ class TimeSpent extends CommonObject public $note; // END MODULEBUILDER PROPERTIES - - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - // public $table_element_line = 'timespent_timespentline'; - - // /** - // * @var string Field with ID of parent key if this object has a parent - // */ - // public $fk_element = 'fk_timespent'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - // public $class_element_line = 'TimeSpentline'; - - // /** - // * @var array List of child tables. To test if we can delete object. - // */ - // protected $childtables = array(); - - // /** - // * @var array List of child tables. To know object to delete on cascade. - // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will - // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object - // */ - // protected $childtablesoncascade = array('timespent_timespentdet'); - - // /** - // * @var TimeSpentLine[] Array of subtable lines - // */ - // public $lines = array(); - - - /** * Constructor * @@ -269,13 +232,6 @@ class TimeSpent extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) { - $object->fetchLines(); - } - - // get lines so they will be clone - //foreach($this->lines as $line) - // $line->fetch_optionals(); // Reset some properties unset($object->id); @@ -359,26 +315,10 @@ class TimeSpent extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - $result = $this->fetchLinesCommon(); - return $result; - } - - /** * Load list of objects in memory from the database. * From b900579b3f143851e6ec06d270cf55db79f11ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Sep 2023 18:16:30 +0200 Subject: [PATCH 3/3] Update timespent.class.php --- htdocs/core/class/timespent.class.php | 52 --------------------------- 1 file changed, 52 deletions(-) diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index c801f342a2d..6958742207d 100755 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -932,28 +932,6 @@ class TimeSpent extends CommonObject $this->initAsSpecimenCommon(); } - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - $objectline = new TimeSpentLine($this->db); - $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_timespent = '.((int) $this->id))); - - if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; - return $result; - } else { - $this->lines = $result; - return $this->lines; - } - } - /** * Returns the reference to the following non used object depending on the active numbering module. * @@ -1047,34 +1025,4 @@ class TimeSpent extends CommonObject 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; - } }