Skip to content

Commit

Permalink
Qual: Fix some phan typing related to getNextValue()
Browse files Browse the repository at this point in the history
# Qual: Fix some phan typing related to getNextValue()

This fixes a few typings in relation to getNextValue().
  • Loading branch information
mdeweerd committed Aug 22, 2024
1 parent a59e933 commit 5d83c6b
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 21 deletions.
3 changes: 2 additions & 1 deletion htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3643,7 +3643,8 @@ public function getNextNumRef($soc)
}

$obj = new $classname();
$numref = "";
'@phan-var-force ModeleNumRefPropales $obj';

$numref = $obj->getNextValue($soc, $this);

if ($numref != "") {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ public function getNextNumRef($soc)
}

$obj = new $classname();
'@phan-var-force ModeleNumRefCommandes $obj';

$numref = $obj->getNextValue($soc, $this);

if ($numref != "") {
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/paiement/class/paiement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,8 @@ public function getNextNumRef($soc, $mode = 'next')
}

$obj = new $classname();
$numref = "";
'@phan-var-force ModeleNumRefPayments $obj';

$numref = $obj->getNextValue($soc, $this);

/**
Expand Down
8 changes: 8 additions & 0 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
}
$error = 0;

// Note: list of strings for objectclass could be extended to accepted/expected classes
'
@phan-var-force "Societe"|"Contact"|"ExpenseReport"|"Partnership"|"Holiday"|"ConferenceOrBoothAttendee"|"Facture"|"CommandeFournisseur" $objectclass
@phan-var-force string $massaction
';


// For backward compatibility
if (!empty($permtoread) && empty($permissiontoread)) {
$permissiontoread = $permtoread;
Expand Down Expand Up @@ -1780,6 +1787,7 @@
if (getDolGlobalString('PROJECT_TASK_ADDON') && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . ".php")) {
require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . '.php';
$modTask = new $obj();
'@phan-var-force ModeleNumRefTask $modTask';
$defaultref = $modTask->getNextValue(0, $clone_task);
}

Expand Down
1 change: 1 addition & 0 deletions htdocs/core/class/timespent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ public function getNextNumRef()

if (class_exists($classname)) {
$obj = new $classname();
'@phan-var-force CommonNumRefGenerator $obj';
$numref = $obj->getNextValue($this);

Check failure on line 957 in htdocs/core/class/timespent.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

timespent.class.php: PhanUndeclaredMethod: Call to undeclared method \CommonNumRefGenerator::getNextValue

if ($numref != '' && $numref != '-1') {
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/bom/mod_bom_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function getExample()
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc, '');
$numExample = $this->getNextValue($mysoc, null);
$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;

Expand All @@ -120,9 +120,9 @@ public function getExample()
/**
* Return next free value
*
* @param Product $objprod Object product
* @param Bom $object Object we need next value for
* @return string|int Next value if OK, 0 if KO
* @param Product $objprod Object product
* @param ?Bom $object Object we need next value for
* @return string|int<-1,0> Next value if OK, 0 if KO
*/
public function getNextValue($objprod, $object)
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/bom/mod_bom_standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public function canBeActivated($object)
/**
* Return next free value
*
* @param Product $objprod Object product
* @param Bom $object Object we need next value for
* @return string|int<-1,-1> Next value if OK, -1 if KO
* @param Product $objprod Object product
* @param ?Bom $object Object we need next value for
* @return string|int<-1,0> Next value if OK, 0 if KO
*/
public function getNextValue($objprod, $object)
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/bom/modules_bom.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ abstract class ModeleNumRefBoms extends CommonNumRefGenerator
/**
* Return next free value
*
* @param Product $objprod Object product
* @param Bom $object Object we need next value for
* @return string|int<-1,-1> Next value if OK, -1 if KO
* @param Product $objprod Object product
* @param ?Bom $object Object we need next value for
* @return string|int<-1,0> Next value if OK, 0 if KO
*/
abstract public function getNextValue($objprod, $object);
}
4 changes: 2 additions & 2 deletions htdocs/core/modules/facture/mod_facture_mars.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ public function canBeActivated($object)
* Return next value not used or last value used
*
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param ?Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string|int<-1,1> Value if OK, <=0 if KO
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/facture/mod_facture_mercure.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getExample()
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc, '');
$numExample = $this->getNextValue($mysoc, null);
$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;

Expand All @@ -139,9 +139,9 @@ public function getExample()
* Return next value not used or last value used
*
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param ?Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string|int<-1,1> Value if OK, <=0 if KO
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/facture/mod_facture_terre.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ public function canBeActivated($object)
* ALTER TABLE llx_facture ADD INDEX calculated_numrefonly_idx (calculated_numrefonly);
*
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param ?Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string|int<-1,1> Value if OK, <=0 if KO
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/facture/modules_facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ abstract class ModeleNumRefFactures extends CommonNumRefGenerator
* Return next value not used or last value used
*
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param ?Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string|int<-1,1> Value if OK, <=0 if KO
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
abstract public function getNextValue($objsoc, $invoice, $mode = 'next');
}

0 comments on commit 5d83c6b

Please sign in to comment.