Skip to content

Commit

Permalink
Types fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed May 10, 2024
1 parent f7d7a8b commit 47bcea9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions galette/lib/Galette/Entity/ScheduledPayment.php
Expand Up @@ -128,7 +128,7 @@ private function loadFromRs(ArrayObject $rs): void
$this->payment_type = new PaymentType($this->zdb, $rs->id_paymenttype);
$this->creation_date = $rs->creation_date;
$this->scheduled_date = $rs->scheduled_date;
$this->amount = $rs->amount;
$this->amount = (float)$rs->amount;
$this->is_paid = (bool)$rs->paid;
$this->comment = $rs->comment;
}
Expand Down Expand Up @@ -520,7 +520,7 @@ public function getAllocation(int $id_cotis): float

$results = $this->zdb->execute($select);
$result = $results->current();
return $result->allocation ?? 0;
return (float)($result->allocation ?? 0);
}

/**
Expand Down
12 changes: 8 additions & 4 deletions galette/lib/Galette/Entity/Transaction.php
Expand Up @@ -273,7 +273,7 @@ private function loadFromRS(ArrayObject $r): void
$pk = self::PK;
$this->id = $r->$pk;
$this->date = $r->trans_date;
$this->amount = $r->trans_amount;
$this->amount = (float)$r->trans_amount;
$this->description = $r->trans_desc;
$adhpk = Adherent::PK;
$this->member = (int)$r->$adhpk;
Expand Down Expand Up @@ -304,9 +304,12 @@ public function check(array $values, array $required, array $disabled): bool|arr
$prop = $this->fields[$key]['propname'];

if (isset($values[$key])) {
$value = trim($values[$key]);
$value = $values[$key];
if (is_string($value)) {
$value = trim($value);
}
} else {
$value = '';
$value = null;
}

// if the field is enabled, check it
Expand All @@ -322,7 +325,8 @@ public function check(array $values, array $required, array $disabled): bool|arr
$this->member = (int)$value;
break;
case 'trans_amount':
$value = strtr($value, ',', '.');
//FIXME: this is a hack to allow comma as decimal separator
$value = strtr((string)$value, ',', '.');
$this->amount = (double)$value;
if (!is_numeric($value)) {
$this->errors[] = _T("- The amount must be an integer!");
Expand Down
2 changes: 1 addition & 1 deletion galette/lib/Galette/Repository/Contributions.php
Expand Up @@ -250,7 +250,7 @@ private function calculateSum(Select $select): void
$results = $this->zdb->execute($sumSelect);
$result = $results->current();
if ($result->contribsum) {
$this->sum = round($result->contribsum, 2);
$this->sum = round((float)$result->contribsum, 2);
}
} catch (Throwable $e) {
Analog::log(
Expand Down
2 changes: 1 addition & 1 deletion galette/lib/Galette/Util/Release.php
Expand Up @@ -187,7 +187,7 @@ public function getReleasesURL(): string
*
* @return string
*/
protected function getDataTocache(): string
protected function getDataTocache(): ?string
{
return $this->latest;
}
Expand Down

0 comments on commit 47bcea9

Please sign in to comment.