See if we can sort out scrutinizer's issue with the hash map
This commit is contained in:
parent
30482890c0
commit
3ad919575d
|
|
@ -5117,47 +5117,47 @@ class Calculation
|
||||||
/**
|
/**
|
||||||
* Extract range values.
|
* Extract range values.
|
||||||
*
|
*
|
||||||
* @param string &$pRange String based range representation
|
* @param string &$range String based range representation
|
||||||
* @param Worksheet $pSheet Worksheet
|
* @param null|Worksheet $worksheet Worksheet
|
||||||
* @param bool $resetLog Flag indicating whether calculation log should be reset or not
|
* @param bool $resetLog Flag indicating whether calculation log should be reset or not
|
||||||
*
|
*
|
||||||
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
|
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
|
||||||
*/
|
*/
|
||||||
public function extractNamedRange(&$pRange = 'A1', ?Worksheet $pSheet = null, $resetLog = true)
|
public function extractNamedRange(&$range = 'A1', ?Worksheet $worksheet = null, $resetLog = true)
|
||||||
{
|
{
|
||||||
// Return value
|
// Return value
|
||||||
$returnValue = [];
|
$returnValue = [];
|
||||||
|
|
||||||
if ($pSheet !== null) {
|
if ($worksheet !== null) {
|
||||||
$pSheetName = $pSheet->getTitle();
|
$pSheetName = $worksheet->getTitle();
|
||||||
if (strpos($pRange, '!') !== false) {
|
if (strpos($range, '!') !== false) {
|
||||||
[$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true);
|
[$pSheetName, $range] = Worksheet::extractSheetTitle($range, true);
|
||||||
$pSheet = $this->spreadsheet->getSheetByName($pSheetName);
|
$worksheet = $this->spreadsheet->getSheetByName($pSheetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named range?
|
// Named range?
|
||||||
$namedRange = DefinedName::resolveName($pRange, $pSheet);
|
$namedRange = DefinedName::resolveName($range, $worksheet);
|
||||||
if ($namedRange === null) {
|
if ($namedRange === null) {
|
||||||
return Functions::REF();
|
return Functions::REF();
|
||||||
}
|
}
|
||||||
|
|
||||||
$pSheet = $namedRange->getWorksheet();
|
$worksheet = $namedRange->getWorksheet();
|
||||||
$pRange = $namedRange->getValue();
|
$range = $namedRange->getValue();
|
||||||
$splitRange = Coordinate::splitRange($pRange);
|
$splitRange = Coordinate::splitRange($range);
|
||||||
// Convert row and column references
|
// Convert row and column references
|
||||||
if (ctype_alpha($splitRange[0][0])) {
|
if (ctype_alpha($splitRange[0][0])) {
|
||||||
$pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
|
$range = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
|
||||||
} elseif (ctype_digit($splitRange[0][0])) {
|
} elseif (ctype_digit($splitRange[0][0])) {
|
||||||
$pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
|
$range = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract range
|
// Extract range
|
||||||
$aReferences = Coordinate::extractAllCellReferencesInRange($pRange);
|
$aReferences = Coordinate::extractAllCellReferencesInRange($range);
|
||||||
if (!isset($aReferences[1])) {
|
if (!isset($aReferences[1])) {
|
||||||
// Single cell (or single column or row) in range
|
// Single cell (or single column or row) in range
|
||||||
[$currentCol, $currentRow] = Coordinate::coordinateFromString($aReferences[0]);
|
[$currentCol, $currentRow] = Coordinate::coordinateFromString($aReferences[0]);
|
||||||
if ($pSheet->cellExists($aReferences[0])) {
|
if ($worksheet->cellExists($aReferences[0])) {
|
||||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
$returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
|
||||||
} else {
|
} else {
|
||||||
$returnValue[$currentRow][$currentCol] = null;
|
$returnValue[$currentRow][$currentCol] = null;
|
||||||
}
|
}
|
||||||
|
|
@ -5166,8 +5166,8 @@ class Calculation
|
||||||
foreach ($aReferences as $reference) {
|
foreach ($aReferences as $reference) {
|
||||||
// Extract range
|
// Extract range
|
||||||
[$currentCol, $currentRow] = Coordinate::coordinateFromString($reference);
|
[$currentCol, $currentRow] = Coordinate::coordinateFromString($reference);
|
||||||
if ($pSheet->cellExists($reference)) {
|
if ($worksheet->cellExists($reference)) {
|
||||||
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
|
$returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue($resetLog);
|
||||||
} else {
|
} else {
|
||||||
$returnValue[$currentRow][$currentCol] = null;
|
$returnValue[$currentRow][$currentCol] = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,13 @@ class HashTable
|
||||||
*/
|
*/
|
||||||
public function getIndexForHashCode(string $hashCode)
|
public function getIndexForHashCode(string $hashCode)
|
||||||
{
|
{
|
||||||
return array_search($hashCode, $this->keyMap, true);
|
$matched = array_search($hashCode, $this->keyMap, true);
|
||||||
|
|
||||||
|
if ($matched === false) {
|
||||||
|
return $matched;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) $matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue