Skip to content

Commit

Permalink
Cope with updated phpstan, and make fk_origin_stock int in multiple l…
Browse files Browse the repository at this point in the history
…ocations
  • Loading branch information
mdeweerd committed Nov 5, 2024
1 parent 284aad5 commit c6d33f9
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 29 deletions.
5 changes: 5 additions & 0 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22045,6 +22045,11 @@ parameters:
count: 1
path: ../../htdocs/opensurvey/class/opensurveysondage.class.php

-
message: "#^Property Opensurveysondage\\:\\:\\$status \\(int\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: ../../htdocs/opensurvey/class/opensurveysondage.class.php

-
message: "#^Left side of && is always true\\.$#"
count: 1
Expand Down
40 changes: 19 additions & 21 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
*/
return [
// # Issue statistics:
// PhanUndeclaredProperty : 560+ occurrences
// PhanUndeclaredProperty : 570+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 520+ occurrences
// PhanUndeclaredGlobalVariable : 350+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 330+ occurrences
// PhanPluginUnknownPropertyType : 230+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 320+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 220+ occurrences
// PhanPossiblyUndeclaredVariable : 160+ occurrences
// PhanPluginUnknownPropertyType : 200+ occurrences
// PhanTypeMismatchProperty : 160+ occurrences
// PhanPluginUnknownArrayMethodParamType : 140+ occurrences
// PhanPossiblyUndeclaredVariable : 120+ occurrences
// PhanPluginUndeclaredVariableIsset : 65+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 60+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 60+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 50+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 50+ occurrences
// PhanRedefineFunction : 45+ occurrences
// PhanPluginEmptyStatementIf : 40+ occurrences
// PhanTypeExpectedObjectPropAccess : 40+ occurrences
// PhanTypeInvalidDimOffset : 35+ occurrences
// PhanPluginEmptyStatementIf : 35+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 35+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 30+ occurrences
// PhanTypeInvalidDimOffset : 30+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
// PhanPluginUnknownObjectMethodCall : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
Expand All @@ -35,10 +35,9 @@ return [
// PhanTypeComparisonFromArray : 10+ occurrences
// PhanTypeMismatchDimFetchNullable : 10+ occurrences
// PhanUndeclaredMethod : 10+ occurrences
// PhanPluginSuspiciousParamPosition : 9 occurrences
// PhanPluginBothLiteralsBinaryOp : 8 occurrences
// PhanPluginSuspiciousParamPosition : 8 occurrences
// PhanPluginDuplicateExpressionBinaryOp : 7 occurrences
// PhanPluginConstantVariableNull : 6 occurrences
// PhanParamTooMany : 5 occurrences
// PhanPossiblyNullTypeMismatchProperty : 5 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
Expand All @@ -48,7 +47,9 @@ return [
// PhanTypeMismatchDimAssignment : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence
// PhanParamTooFew : 1 occurrence
// PhanPluginRedundantReturnComment : 1 occurrence
// PhanTypeConversionFromArray : 1 occurrence
// PhanTypeMismatchArgumentReal : 1 occurrence
// PhanTypeMismatchReturn : 1 occurrence
// PhanTypeSuspiciousStringExpression : 1 occurrence

Expand Down Expand Up @@ -121,7 +122,7 @@ return [
'htdocs/commande/list.php' => ['PhanUndeclaredProperty'],
'htdocs/commande/list_det.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/commande/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/accounting-files.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/accounting-files.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'],
'htdocs/compta/bank/account_statement_document.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/bank/annuel.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/bank/bankentries_list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
Expand Down Expand Up @@ -257,7 +258,7 @@ return [
'htdocs/core/class/notify.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/smtps.class.php' => ['PhanTypeConversionFromArray'],
'htdocs/core/class/timespent.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
'htdocs/core/customreports.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetchNullable'],
'htdocs/core/customreports.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginRedundantReturnComment', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetchNullable'],
'htdocs/core/datepicker.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/core/db/sqlite3.class.php' => ['PhanTypeMismatchReturn'],
'htdocs/core/extrafieldsinimport.inc.php' => ['PhanTypeMismatchArgumentNullableInternal'],
Expand All @@ -270,8 +271,7 @@ return [
'htdocs/core/lib/images.lib.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/lib/pdf.lib.php' => ['PhanUndeclaredProperty'],
'htdocs/core/lib/project.lib.php' => ['PhanUndeclaredProperty'],
'htdocs/core/lib/xcal.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/core/menus/standard/auguria.lib.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/core/lib/xcal.lib.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/asset/mod_asset_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/barcode/doc/phpbarcode.modules.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable'],
Expand Down Expand Up @@ -363,8 +363,6 @@ return [
'htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php' => ['PhanUndeclaredProperty'],
'htdocs/cron/card.php' => ['PhanPluginBothLiteralsBinaryOp'],
'htdocs/cron/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/datapolicy/lib/datapolicy.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/datapolicy/class/datapolicycron.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/debugbar/class/DataCollector/DolConfigCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolMemoryCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
Expand Down Expand Up @@ -608,7 +606,7 @@ return [
'htdocs/public/project/suggestconference.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/public/project/viewandvote.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/public/recruitment/view.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/public/stripe/ipn.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'],
'htdocs/public/stripe/ipn.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/public/test/test_arrays.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/public/test/test_forms.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/public/ticket/create_ticket.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetchNullable', 'PhanTypeMismatchProperty'],
Expand Down Expand Up @@ -664,7 +662,7 @@ return [
'htdocs/societe/tpl/linesalesrepresentative.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/societe/website.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginSuspiciousParamPosition'],
'htdocs/stripe/class/stripe.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchProperty'],
'htdocs/stripe/class/stripe.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchProperty'],
'htdocs/supplier_proposal/card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/supplier_proposal/class/api_supplier_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'],
'htdocs/supplier_proposal/class/supplier_proposal.class.php' => ['PhanUndeclaredProperty'],
Expand All @@ -691,7 +689,7 @@ return [
'htdocs/theme/md/info-box.inc.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/theme/md/progress.inc.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/ticket/card.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/actions_ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/ticket/class/actions_ticket.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/ticket/class/cticketcategory.class.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/ticket.class.php' => ['PhanUndeclaredProperty'],
Expand All @@ -716,7 +714,7 @@ return [
'htdocs/webhook/target_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/webportal/class/context.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/webportal/class/controller.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanUndeclaredProperty'],
'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/webportal/class/webportalpropal.class.php' => ['PhanUndeclaredProperty'],
'htdocs/webservices/server_actioncomm.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'],
Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@
$arrayfields[$tableprefix.'.'.$key] = array(
'label' => $val['label'],
'checked' => (($visible < 0) ? 0 : 1),
'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
'position' => $val['position'],
'enabled' => (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
'position' => (int) $val['position'],
'help' => isset($val['help']) ? $val['help'] : ''
);
}
Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,18 @@ abstract class CommonObject
public $newref;

/**
* @var int|array<int, string> The object's status. Use status instead.
* @var null|int|array<int, string> The object's status. Use status instead.
* @deprecated Use $status instead.
* @see $status
* @see setStatut(), $status
*/
public $statut;

/**
* @var int|array<int, string> The object's status (an int).
* @var null|int|array<int, string> The object's status (an int).
* Or an array listing all the potential status of the object:
* array: int of the status => translated label of the status
* In some classes status must be able to be null.
* See for example the Account class.
* @see setStatut()
*/
Expand Down
2 changes: 1 addition & 1 deletion htdocs/expedition/class/expeditionlinebatch.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function create($id_line_expdet, $f_user = null, $notrigger = 0)
$sql .= ", ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'");
$sql .= ", ".(!empty($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'"));
$sql .= ", ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty); // dluo_qty deprecated, use qty
$sql .= ", ".(empty($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock);
$sql .= ", ".((int) $this->fk_origin_stock);
$sql .= ", ".(empty($this->fk_warehouse) ? 'NULL' : $this->fk_warehouse);
$sql .= ")";

Expand Down
4 changes: 2 additions & 2 deletions htdocs/fourn/class/fournisseur.commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CommandeFournisseur extends CommonOrder

/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
* @var int<0,1>
*/
public $restrictiononfksoc = 1;

Expand Down Expand Up @@ -115,7 +115,7 @@ class CommandeFournisseur extends CommonOrder
public $ref_fourn;

/**
* @var int<0,5>
* @var ?int<0,9>
*/
public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Ordered/Process running -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
// -> 7=Canceled/Never received -> (reopen) 3=Process running
Expand Down
2 changes: 1 addition & 1 deletion htdocs/webportal/class/html.formcardwebportal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function init($elementEn, $id = 0, $permissiontoread = 0, $permissiontoad
$this->backtopagejsfields = $backtopagejsfields;
$this->cancel = $cancel;
$this->elementEn = $elementEn;
$this->id = $id;
$this->id = (int) $id;
$this->object = $object;
$this->permissiontoread = $permissiontoread;
$this->permissiontoadd = $permissiontoadd;
Expand Down

0 comments on commit c6d33f9

Please sign in to comment.