Skip to content

Commit

Permalink
keep only commonobject property oldcopy (#32123)
Browse files Browse the repository at this point in the history
* clean properties

* clean properties

* clean properties

* clean properties

* clean phpcs

* clean phan

* clean code

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
  • Loading branch information
frederic34 and eldy authored Nov 27, 2024
1 parent 353633c commit 13b8f5f
Show file tree
Hide file tree
Showing 18 changed files with 6 additions and 81 deletions.
6 changes: 0 additions & 6 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -27870,12 +27870,6 @@ parameters:
count: 1
path: ../../htdocs/product/stock/movement_list.php

-
message: '#^Variable \$whClass might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/product/stock/movement_list.php

-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
Expand Down
6 changes: 0 additions & 6 deletions htdocs/asset/class/asset.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,6 @@ class Asset extends CommonObject
*/
public $status;

/**
* @var static object oldcopy
*/
public $oldcopy;


/**
* @var AssetDepreciationOptions Used for computed fields of depreciation options class.
*/
Expand Down
5 changes: 0 additions & 5 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ class Propal extends CommonObject
*/
public $ref_customer;

/**
* @var static oldcopy with propal properties
*/
public $oldcopy;

/**
* Status of the quote
* @var int
Expand Down
5 changes: 0 additions & 5 deletions htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ class Facture extends CommonInvoice
*/
public $tab_next_situation_invoice = array();

/**
* @var static object oldcopy
*/
public $oldcopy;

/**
* @var float percentage of retainage
*/
Expand Down
7 changes: 0 additions & 7 deletions htdocs/contact/class/contact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,6 @@ class Contact extends CommonObject
public $ip;
// END MODULEBUILDER PROPERTIES


/**
* Old copy
* @var static
*/
public $oldcopy; // To contain a clone of this when we need to save old properties of object

/**
* @var array<int,array{id:int,socid:int,element:string,source:string,code:string,label:string}> roles
*/
Expand Down
5 changes: 0 additions & 5 deletions htdocs/core/class/comment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ class Comment extends CommonObject

public $comments = array();

/**
* @var static Object oldcopy
*/
public $oldcopy;


/**
* Constructor
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ abstract class CommonObject
private $linkedObjectsFullLoaded = array();

/**
* @var ?mixed To store a cloned copy of the object before editing it (to keep track of its former properties)
* @var ?static To store a cloned copy of the object before editing it (to keep track of its former properties)
*/
public $oldcopy;

Expand Down
5 changes: 0 additions & 5 deletions htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ class Product extends CommonObject
*/
public $fk_element = 'fk_product';

/**
* @var static
*/
public $oldcopy;

/**
* @var array<string, array<string>> List of child tables. To test if we can delete object.
*/
Expand Down
4 changes: 0 additions & 4 deletions htdocs/product/stock/class/productlot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ public function createFromClone(User $user, $fromid)
*/
public function loadStatsExpedition($socid = 0)
{
// phpcs:enable
global $user, $hookmanager, $action;

$sql = "SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,";
Expand Down Expand Up @@ -923,7 +922,6 @@ public function loadStatsExpedition($socid = 0)
*/
public function loadStatsSupplierOrder($socid = 0)
{
// phpcs:enable
global $user, $hookmanager, $action;

$sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,";
Expand Down Expand Up @@ -998,7 +996,6 @@ public function loadStatsSupplierOrder($socid = 0)
*/
public function loadStatsReception($socid = 0)
{
// phpcs:enable
global $user, $hookmanager, $action;

$sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,";
Expand Down Expand Up @@ -1072,7 +1069,6 @@ public function loadStatsReception($socid = 0)
*/
public function loadStatsMo($socid = 0)
{
// phpcs:enable
global $user, $hookmanager, $action;

$error = 0;
Expand Down
3 changes: 1 addition & 2 deletions htdocs/product/stock/movement_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@
}

if ($action == 'update_extras' && $permissiontoadd) {
$whClass = get_class($whClass);
$whClass::$oldcopy = dol_clone($tmpwarehouse, 2);
$tmpwarehouse->oldcopy = dol_clone($tmpwarehouse, 2); // @phan-suppress-current-line PhanTypeMismatchProperty

// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse, GETPOST('attribute', 'restricthtml'));
Expand Down
5 changes: 0 additions & 5 deletions htdocs/projet/class/project.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ class Project extends CommonObject
*/
public $email_msgid;

/**
* @var ?static
*/
public $oldcopy;

/**
* @var array<int,int> Used to store workload details of a projet (array[day])
*/
Expand Down
2 changes: 1 addition & 1 deletion htdocs/public/payment/newpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@
}
// - If a new amount was posted from the form
if ($caneditamount && GETPOSTISSET('newamount') && GETPOSTFLOAT('newamount', 'MT') > 0) {
$amount = GETPOSTFLOAT('newamount', 'MT');
$amount = GETPOSTFLOAT('newamount', 'MT');
}
// - If a min is set or an amount from the posted form, we take them into account
$amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"));
Expand Down
5 changes: 0 additions & 5 deletions htdocs/resource/class/dolresource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ class Dolresource extends CommonObject
*/
public $cache_code_type_resource;

/**
* @var static Clone of object before changing it
*/
public $oldcopy;


/**
* Constructor
Expand Down
5 changes: 0 additions & 5 deletions htdocs/societe/class/societe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ class Societe extends CommonObject
*/
public $restrictiononfksoc = 1;

/**
* @var static To store a cloned copy of object before to edit it and keep track of old properties
*/
public $oldcopy;

/**
* array of supplier categories
* @var string[]
Expand Down
6 changes: 3 additions & 3 deletions htdocs/societe/paymentmodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
}

if (!$error) {
$companybankaccount->oldcopy = dol_clone($companybankaccount, 2);
$companybankaccount->oldcopy = dol_clone($companybankaccount, 2); // @phan-suppress-current-line PhanTypeMismatchProperty

$companybankaccount->socid = $object->id;

Expand Down Expand Up @@ -254,7 +254,7 @@

$companypaymentmode->fetch($id);
if (!$error) {
$companypaymentmode->oldcopy = dol_clone($companypaymentmode, 2);
$companypaymentmode->oldcopy = dol_clone($companypaymentmode, 2); // @phan-suppress-current-line PhanTypeMismatchProperty

$companypaymentmode->fk_soc = $object->id;

Expand Down Expand Up @@ -311,7 +311,7 @@
// Ajout
$companybankaccount = new CompanyBankAccount($db);

$companybankaccount->socid = $object->id;
$companybankaccount->socid = $object->id;

$companybankaccount->fetch_thirdparty();

Expand Down
6 changes: 0 additions & 6 deletions htdocs/ticket/class/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,11 @@ class Ticket extends CommonObject
*/
public $ip;

/**
* @var static Save the ticket before an update operation (for triggers)
*/
public $oldcopy;

/**
* @var Ticket[] Array of Tickets
*/
public $lines;


/**
* @var string Regex pour les images
*/
Expand Down
5 changes: 0 additions & 5 deletions htdocs/user/class/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ class User extends CommonObject
*/
public $id = 0;

/**
* @var static old copy of User
*/
public $oldcopy;

/**
* @var int
* @deprecated Use $status
Expand Down
5 changes: 0 additions & 5 deletions htdocs/user/class/usergroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ class UserGroup extends CommonObject
*/
public $all_permissions_are_loaded;

/**
* @var static
*/
public $oldcopy; // To contains a clone of this when we need to save old properties of object

public $fields = array(
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'default' => '1', 'index' => 1, 'position' => 5),
Expand Down

0 comments on commit 13b8f5f

Please sign in to comment.