Skip to content

Commit

Permalink
Fixed casting to make tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
hywak committed Oct 29, 2021
1 parent ea7c18c commit 45a3aa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions core/Common.php
Expand Up @@ -543,14 +543,14 @@ public static function getRequestVar($varName, $varDefault = null, $varType = nu
$ok = true;
}
} elseif ($varType === 'integer') {
if ((string)$value === (string)(int)$value) {
if (!is_array($value) && (string) $value === (string)(int)$value) {
$ok = true;
}
} elseif ($varType === 'float') {
$valueToCompare = (string)(float)$value;
$valueToCompare = Common::forceDotAsSeparatorForDecimalPoint($valueToCompare);

if ($value === $valueToCompare) {
if ((string) $value === $valueToCompare) {
$ok = true;
}
} elseif ($varType === 'array') {
Expand Down
18 changes: 5 additions & 13 deletions core/DataTable.php
Expand Up @@ -673,14 +673,12 @@ public function getRowFromLabel($label)
if (is_int($rowId) && isset($this->rows[$rowId])) {
return $this->rows[$rowId];
}
if ($rowId === self::ID_SUMMARY_ROW
&& !empty($this->summaryRow)
) {
if ((int) $rowId === self::ID_SUMMARY_ROW && !empty($this->summaryRow)) {
return $this->summaryRow;
}
if (empty($rowId)
&& !empty($this->totalsRow)
&& $label === $this->totalsRow->getColumn('label')
&& (string) $label === (string) $this->totalsRow->getColumn('label')
) {
return $this->totalsRow;
}
Expand Down Expand Up @@ -710,9 +708,7 @@ public function getRowIdFromLabel($label)
if (!isset($this->rowsIndexByLabel[$label])) {
// in case label is '-1' and there is no normal row w/ that label. Note: this is for BC since
// in the past, it was possible to get the summary row by searching for the label '-1'
if ($label === self::LABEL_SUMMARY_ROW
&& !is_null($this->summaryRow)
) {
if ($label === (string) self::LABEL_SUMMARY_ROW && !is_null($this->summaryRow)) {
return self::ID_SUMMARY_ROW;
}

Expand Down Expand Up @@ -765,9 +761,7 @@ public function rebuildIndex()
*/
public function getRowFromId($id)
{
if ($id === self::ID_SUMMARY_ROW
&& !is_null($this->summaryRow)
) {
if ((int) $id === self::ID_SUMMARY_ROW && !is_null($this->summaryRow)) {
return $this->summaryRow;
}

Expand Down Expand Up @@ -1245,9 +1239,7 @@ public static function isEqual(DataTable $table1, DataTable $table2)

foreach ($rows1 as $row1) {
$row2 = $table2->getRowFromLabel($row1->getColumn('label'));
if ($row2 === false
|| !Row::isEqual($row1, $row2)
) {
if ($row2 === false || !Row::isEqual($row1, $row2)) {
return false;
}
}
Expand Down

0 comments on commit 45a3aa5

Please sign in to comment.