noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 30/32: Function load : give the return type


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 30/32: Function load : give the return type
Date: Thu, 5 Jan 2023 14:18:32 -0500 (EST)

sparkyx pushed a commit to branch devel
in repository noalyss.

commit 073c0efbef1bfd53c72fc6fe44cb380cd59c1d5a
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Thu Jan 5 11:37:26 2023 +0100

    Function load : give the return type
---
 include/class/acc_account.class.php                  | 4 ++--
 include/class/acc_account_ledger.class.php           | 2 +-
 include/class/acc_bilan.class.php                    | 2 +-
 include/class/acc_ledger.class.php                   | 2 +-
 include/class/acc_ledger_info.class.php              | 2 +-
 include/class/acc_operation_note.class.php           | 4 ++--
 include/class/acc_payment.class.php                  | 2 +-
 include/class/acc_report.class.php                   | 8 +++++---
 include/class/acc_tva.class.php                      | 4 ++--
 include/class/anc_balance_simple.class.php           | 2 +-
 include/class/anc_group.class.php                    | 2 +-
 include/class/document_modele.class.php              | 2 +-
 include/class/extension.class.php                    | 2 +-
 include/class/fiche.class.php                        | 2 +-
 include/class/fiche_def.class.php                    | 2 +-
 include/class/follow_up_detail.class.php             | 2 +-
 include/class/forecast.class.php                     | 2 +-
 include/class/lettering.class.php                    | 1 +
 include/class/noalyss_appearance.class.php           | 2 +-
 include/class/noalyss_user.class.php                 | 2 +-
 include/class/periode.class.php                      | 6 +++---
 include/class/pre_operation.class.php                | 2 +-
 include/class/todo_list.class.php                    | 2 +-
 include/database/acc_plan_sql.class.php              | 5 +++--
 include/database/v_contact_sql.class.php             | 2 +-
 include/database/v_currency_last_value_sql.class.php | 5 +++--
 include/lib/data_sql.class.php                       | 8 ++++----
 include/lib/table_data_sql.class.php                 | 2 +-
 unit-test/include/class/acc_account.Test.php         | 2 +-
 29 files changed, 45 insertions(+), 40 deletions(-)

diff --git a/include/class/acc_account.class.php 
b/include/class/acc_account.class.php
index e5c7e10f1..1a8abf786 100644
--- a/include/class/acc_account.class.php
+++ b/include/class/acc_account.class.php
@@ -94,9 +94,9 @@ class Acc_Account
      *        the data member are set
      * \return false if this account doesn't exist otherwise true
      */
-    function load()
+    function load():bool
     {
-      $this->data_sql->load();
+      return $this->data_sql->load();
     }
     
     function count($p_value)
diff --git a/include/class/acc_account_ledger.class.php 
b/include/class/acc_account_ledger.class.php
index c1b2d720e..730c7d680 100644
--- a/include/class/acc_account_ledger.class.php
+++ b/include/class/acc_account_ledger.class.php
@@ -256,7 +256,7 @@ class Acc_Account_Ledger
      *        the data member are set
      * \return false if this account doesn't exist otherwise true
      */
-    function load()
+    function load():bool
     {
         $ret=$this->db->exec_sql("select pcm_lib,pcm_val_parent from
                                  tmp_pcmn where pcm_val=$1",array($this->id));
diff --git a/include/class/acc_bilan.class.php 
b/include/class/acc_bilan.class.php
index 85c8dda69..071ac941f 100644
--- a/include/class/acc_bilan.class.php
+++ b/include/class/acc_bilan.class.php
@@ -259,7 +259,7 @@ class Acc_Bilan
         $this->to=$http->get("to_periode","number",-1);
     }
     /*!\brief load from the database the document data  */
-    function load()
+    function load():void
     {
         try
         {
diff --git a/include/class/acc_ledger.class.php 
b/include/class/acc_ledger.class.php
index f198149d8..6fc21baeb 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -2561,7 +2561,7 @@ class Acc_Ledger  extends jrn_def_sql
      */
     function display_ledger()
     {
-        if ($this->load()==-1)
+        if ($this->load()==false)
         {
             throw new Exception(_("Journal n'existe pas"), -1);
         }
diff --git a/include/class/acc_ledger_info.class.php 
b/include/class/acc_ledger_info.class.php
index 376c99334..c0f0c187e 100644
--- a/include/class/acc_ledger_info.class.php
+++ b/include/class/acc_ledger_info.class.php
@@ -94,7 +94,7 @@ class Acc_Ledger_Info
      * @brief load the todo_list row thanks it's ID
      * @return boolean true if found else false
      */
-    function load()
+    function load():bool
     {
         $sql="select jr_id,id_type,ji_value from jrn_info where ji_id=$1";
         $r=$this->cn->exec_sql($sql,[$this->ji_id]);
diff --git a/include/class/acc_operation_note.class.php 
b/include/class/acc_operation_note.class.php
index 47f829a33..9a2638347 100644
--- a/include/class/acc_operation_note.class.php
+++ b/include/class/acc_operation_note.class.php
@@ -75,7 +75,7 @@ class Acc_Operation_Note
         return new Acc_Operation_Note(new Jrn_Note_SQL($cn,$n_id));
 
     }
-    function save()
+    function save():Acc_Operation_Note
     {
         $cn=Dossier::connect();
         $this->jrn_note_sql->setp("jr_id",$this->operation_id);
@@ -104,7 +104,7 @@ class Acc_Operation_Note
     function getOperation_id() {
         return $this->operation_id;
     }
-    function load()
+    function load():void
     {
         $this->jrn_note_sql->load();
         $this->operation_id=$this->jrn_note_sql->jr_id;
diff --git a/include/class/acc_payment.class.php 
b/include/class/acc_payment.class.php
index 4358b36a9..d73f17bc7 100644
--- a/include/class/acc_payment.class.php
+++ b/include/class/acc_payment.class.php
@@ -84,7 +84,7 @@ class Acc_Payment
         return var_export(self::$variable,true);
     }
   
-    public function load()
+    public function load():bool
     {
         $sql='select mp_id,mp_lib,mp_fd_id,mp_jrn_def_id,mp_qcode,jrn_def_id 
from payment_method '.
              ' where mp_id = $1';
diff --git a/include/class/acc_report.class.php 
b/include/class/acc_report.class.php
index 899a156a1..fd9d97a0c 100644
--- a/include/class/acc_report.class.php
+++ b/include/class/acc_report.class.php
@@ -122,9 +122,10 @@ class Acc_Report
         $this->form_definition->save();
     }
   
-    /*!\brief the fr_id MUST be set before calling
+    /*!
+     * \brief the fr_id MUST be set before calling
      */
-    function load()
+    function load():void
     {
        $this->form_definition->load();
 
@@ -133,7 +134,8 @@ class Acc_Report
     {
        $this->form_definition->delete();
     }
-    /*!\brief get a list from form_definition of all defined form
+    /*!
+     * \brief get a list from form_definition of all defined form
      *
      *\return array of object rapport
      *
diff --git a/include/class/acc_tva.class.php b/include/class/acc_tva.class.php
index 1a5e5cfe8..4f719c5ff 100644
--- a/include/class/acc_tva.class.php
+++ b/include/class/acc_tva.class.php
@@ -108,7 +108,7 @@ class Acc_Tva
      *@note if the label is not found then we get an message error, so the 
best is probably
      *to initialize the VAT object with default value
      */
-    public function load()
+    public function load():int
     {
         $this->tva_rate_sql->setp("tva_id",$this->tva_id);
 
@@ -122,7 +122,7 @@ class Acc_Tva
      */
     public function get_side($p_side)
     {
-        if ( strlen($this->tva_poste) == 0 ) $this->load();
+        if ( strlen($this->tva_poste??"") == 0 ) $this->load();
         list($deb,$cred)=explode(",",$this->tva_poste);
         switch ($p_side)
         {
diff --git a/include/class/anc_balance_simple.class.php 
b/include/class/anc_balance_simple.class.php
index 80bc60968..98801b703 100644
--- a/include/class/anc_balance_simple.class.php
+++ b/include/class/anc_balance_simple.class.php
@@ -35,7 +35,7 @@ class Anc_Balance_Simple extends Anc_Print
     /*!
      * \brief load the data from the database
      *
-     * \return array
+     * \return array or  null
      */
     function load()
     {
diff --git a/include/class/anc_group.class.php 
b/include/class/anc_group.class.php
index 50ffb94ac..3a0c543df 100644
--- a/include/class/anc_group.class.php
+++ b/include/class/anc_group.class.php
@@ -83,7 +83,7 @@ class Anc_Group extends Anc_Print
      * @brief load the todo_list row thanks it's ID
      * @return boolean true if found else false
      */
-    function load()
+    function load():bool
     {
         $sql="select ga_id, ga_description,pa_id from groupe_analytique where".
              " ga_id = $1";
diff --git a/include/class/document_modele.class.php 
b/include/class/document_modele.class.php
index 571e3a499..2f0ef29ab 100644
--- a/include/class/document_modele.class.php
+++ b/include/class/document_modele.class.php
@@ -286,7 +286,7 @@ class Document_modele
     }
     /*!\brief load the value of a document_modele,the ag_id variable must be 
set
      */
-    function load()
+    function load():void
     {
         $array=$this->cn->get_array("SELECT md_id, md_name, md_lob, md_type, 
md_filename, md_mimetype,md_affect".
                                     " FROM document_modele where 
md_id=$1",array($this->md_id));
diff --git a/include/class/extension.class.php 
b/include/class/extension.class.php
index 312049742..988f6702d 100644
--- a/include/class/extension.class.php
+++ b/include/class/extension.class.php
@@ -71,7 +71,7 @@ class Extension extends Menu_Ref_sql
     function search($p_what)
     {
         $this->me_code=strtoupper($p_what);
-        if ($this->load()==-1)
+        if ($this->load()==false)
             return null;
         return 1;
     }
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index ef4a90e45..c129e11c8 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -637,7 +637,7 @@ class Fiche
     }
     /*!\brief Synonum of fiche::getAttribut
      */
-    function load() 
+    function load() :void
     {
         $this->getAttribut();
     }
diff --git a/include/class/fiche_def.class.php 
b/include/class/fiche_def.class.php
index 261ff94ce..7536c38e3 100644
--- a/include/class/fiche_def.class.php
+++ b/include/class/fiche_def.class.php
@@ -105,7 +105,7 @@ class Fiche_Def
      * @brief  alias for Fiche_Def->get(),
      * @return void
      */
-    function load()
+    function load():void
     {
         $this->get();
     }
diff --git a/include/class/follow_up_detail.class.php 
b/include/class/follow_up_detail.class.php
index dccfc0763..70aa42f00 100644
--- a/include/class/follow_up_detail.class.php
+++ b/include/class/follow_up_detail.class.php
@@ -169,7 +169,7 @@ class Follow_Up_Detail
      * @brief load the todo_list row thanks it's ID
      * @return boolean true if found else false
      */
-    public function load()
+    public function load():bool
     {
         $sql="SELECT ad_id, f_id, ad_text, ad_pu, ad_quant, ad_tva_id, 
ad_tva_amount,
              ad_total_amount, ag_id   FROM action_detail".
diff --git a/include/class/forecast.class.php b/include/class/forecast.class.php
index 49fd909cd..e7faf9e10 100644
--- a/include/class/forecast.class.php
+++ b/include/class/forecast.class.php
@@ -124,7 +124,7 @@ class Forecast
      * @brief load from db
      * @return boolean true if found else false 
      */
-    public function load()
+    public function load():bool
     {
         $sql="select f_id, f_name,f_start_date ,f_end_date from forecast where 
f_id=$1";
         $res=$this->cn->exec_sql(
diff --git a/include/class/lettering.class.php 
b/include/class/lettering.class.php
index 5a8e81cc6..799e8acbc 100644
--- a/include/class/lettering.class.php
+++ b/include/class/lettering.class.php
@@ -460,6 +460,7 @@ class Lettering
     public function load()
     {
         
+        throw new Exception('load not implemented');
     }
 
     public function delete()
diff --git a/include/class/noalyss_appearance.class.php 
b/include/class/noalyss_appearance.class.php
index 796f91c6f..0d056591b 100644
--- a/include/class/noalyss_appearance.class.php
+++ b/include/class/noalyss_appearance.class.php
@@ -71,7 +71,7 @@ class Noalyss_Appearance
         $this->aColor=self::$aCSSColor;
     }
 
-    function load()
+    function load():void
     {
         $cn = Dossier::connect();
         $aColor = $cn->get_array("select a_code,a_value from parm_appearance");
diff --git a/include/class/noalyss_user.class.php 
b/include/class/noalyss_user.class.php
index 5eb0a0c05..f7bce1716 100644
--- a/include/class/noalyss_user.class.php
+++ b/include/class/noalyss_user.class.php
@@ -346,7 +346,7 @@ class Noalyss_User
      * return -1 if nothing is found or the use_id
      */
 
-    function load()
+    function load():int
     {
         /* if this->id == -1, it is unknown so we have to retrieve it from
           the database thanks it login */
diff --git a/include/class/periode.class.php b/include/class/periode.class.php
index d42d5dc41..ec58997cc 100644
--- a/include/class/periode.class.php
+++ b/include/class/periode.class.php
@@ -297,7 +297,7 @@ EOF;
      * \return 0 on success and -1 on error
      */
 
-    function load()
+    function load():int
     {
         if ($this->p_id=='')
             $this->p_id=-1;
@@ -330,11 +330,11 @@ EOF;
                 array($p_exercice));
         $rMax=new Periode($this->cn);
         $rMax->p_id=$max;
-        if ($rMax->load())
+        if ($rMax->load() == -1)
             throw new Exception('Periode n\'existe pas');
         $rMin=new Periode($this->cn);
         $rMin->p_id=$min;
-        if ($rMin->load())
+        if ($rMin->load() == -1)
             throw new Exception('Periode n\'existe pas');
         return array($rMax, $rMin);
     }
diff --git a/include/class/pre_operation.class.php 
b/include/class/pre_operation.class.php
index 6983414e1..710977027 100644
--- a/include/class/pre_operation.class.php
+++ b/include/class/pre_operation.class.php
@@ -182,7 +182,7 @@ class Pre_operation
     /*!\brief load the data from the database and return an array
      * \return an double array containing all the data from database
      */
-    function load()
+    function load():array
     {
         $this->isloaded=true;
         //------------------------------------------
diff --git a/include/class/todo_list.class.php 
b/include/class/todo_list.class.php
index 656e89e32..bd05175d9 100644
--- a/include/class/todo_list.class.php
+++ b/include/class/todo_list.class.php
@@ -210,7 +210,7 @@ class Todo_List
      * @brief load the todo_list row thanks it's ID
      * @return boolean true if found else false
      */
-    public function load()
+    public function load():bool
     {
 
         $sql="select tl_id,tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as 
tl_date,is_public,use_login
diff --git a/include/database/acc_plan_sql.class.php 
b/include/database/acc_plan_sql.class.php
index 85eab7a35..c26023c85 100644
--- a/include/database/acc_plan_sql.class.php
+++ b/include/database/acc_plan_sql.class.php
@@ -121,7 +121,7 @@ class Acc_Plan_SQL extends Data_SQL
     {
         return $this->id;
     }
-    public function load()
+    public function load():bool
     {
         $pk=$this->primary_key;
         if ( $this->get_limit_fiche_qcode() != 0 ) 
@@ -135,13 +135,14 @@ class Acc_Plan_SQL extends Data_SQL
         if ($this->cn->count()==0)
         {
             $this->$pk=-1;
-            return;
+            return false;
         }
 
         foreach ($result[0] as $key=> $value)
         {
             $this->$key=$value;
         }
+        return true;
     }
 
     public function seek($cond='', $p_array=null)
diff --git a/include/database/v_contact_sql.class.php 
b/include/database/v_contact_sql.class.php
index 36e93a7e5..a16e01936 100644
--- a/include/database/v_contact_sql.class.php
+++ b/include/database/v_contact_sql.class.php
@@ -63,7 +63,7 @@ class V_Contact_SQL extends Data_SQL
         throw new Exception("not implemented");
     }
 
-    function load()
+    function load():bool
     {
        $array=$this->cn->get_row("select * from ".$this->table." where 
f_id=$1",array($this->f_id));
        if (empty ($array) ) { $this->f_id=-1;return false;}
diff --git a/include/database/v_currency_last_value_sql.class.php 
b/include/database/v_currency_last_value_sql.class.php
index e2ca21bfe..3f239f75f 100644
--- a/include/database/v_currency_last_value_sql.class.php
+++ b/include/database/v_currency_last_value_sql.class.php
@@ -108,7 +108,7 @@ class V_Currency_Last_Value_SQL extends Data_SQL
         
     }
 
-    public function load()
+    public function load():bool
     {
         $sql=" select ";
         $sep="";
@@ -133,13 +133,14 @@ class V_Currency_Last_Value_SQL extends Data_SQL
         if ($this->cn->count()==0)
         {
             $this->$pk=-1;
-            return;
+            return false;
         }
 
         foreach ($result[0] as $key=> $value)
         {
             $this->$key=$value;
         }
+        return true;
     }
 
     function seek($cond='', $p_array=null)
diff --git a/include/lib/data_sql.class.php b/include/lib/data_sql.class.php
index 0333a9696..37b0bc1f5 100644
--- a/include/lib/data_sql.class.php
+++ b/include/lib/data_sql.class.php
@@ -117,7 +117,7 @@ abstract class Data_SQL
         if ( empty($this->date_format) )         
$this->date_format="DD.MM.YYYY";
     }
 /**
- * Insert or update : if the row already exists, update otherwise insert
+ *@brief Insert or update : if the row already exists, update otherwise insert
  */
     public function save()
     {
@@ -199,7 +199,7 @@ abstract class Data_SQL
           return $this->$pk;
     }
 
-    abstract function load();
+    abstract function load():bool;
 
     public function get_info()
     {
@@ -241,7 +241,7 @@ abstract class Data_SQL
     }
     /**
      * 
-     * Turn an object (row) into an array, and the key could be prefixed with 
$prefix
+     * @brief Turn an object (row) into an array, and the key could be 
prefixed with $prefix
      * @param string $prefix before the key 
      * @return array
      */
@@ -277,7 +277,7 @@ abstract class Data_SQL
     abstract  function seek($cond='', $p_array=null);
 
     /**
-     * get_seek return the next object, the return of the query must have all 
the column
+     * @brief get_seek return the next object, the return of the query must 
have all the column
      * of the object
      * @param $p_ret is the return value of an exec_sql
      * @param $idx is the index
diff --git a/include/lib/table_data_sql.class.php 
b/include/lib/table_data_sql.class.php
index 4c55b377f..2d130cf3f 100644
--- a/include/lib/table_data_sql.class.php
+++ b/include/lib/table_data_sql.class.php
@@ -174,7 +174,7 @@ abstract class Table_Data_SQL extends Data_SQL
    /***
     * @brief load a row , corresponding to the primary key
     */
-    public function load()
+    public function load():bool
     {
         $sql=$this->build_query();
         $pk=$this->primary_key;
diff --git a/unit-test/include/class/acc_account.Test.php 
b/unit-test/include/class/acc_account.Test.php
index c6d59e39d..d607d5ac2 100644
--- a/unit-test/include/class/acc_account.Test.php
+++ b/unit-test/include/class/acc_account.Test.php
@@ -60,7 +60,7 @@ class Acc_AccountTest extends TestCase
     public function testLoad()
     {
         $r=$this->object->load();
-        $this->assertNotEquals($r,-1);
+        $this->assertNotEquals($r,false);
     }
 
     /**



reply via email to

[Prev in Thread] Current Thread [Next in Thread]