Skip to content

Commit 3e5f1fe

Browse files
authored
Merge branch 'master' into issue4108
2 parents a157e3f + fcca8ac commit 3e5f1fe

File tree

64 files changed

+422
-251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+422
-251
lines changed

composer.lock

Lines changed: 106 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class Calculation
6969

7070
/**
7171
* Instance of this class.
72-
*
73-
* @var ?Calculation
7472
*/
7573
private static ?Calculation $instance = null;
7674

@@ -3272,10 +3270,8 @@ private static function translateFormula(array $from, array $to, string $formula
32723270
return $formula;
32733271
}
32743272

3275-
/** @var ?array */
32763273
private static ?array $functionReplaceFromExcel;
32773274

3278-
/** @var ?array */
32793275
private static ?array $functionReplaceToLocale;
32803276

32813277
/**
@@ -3321,10 +3317,8 @@ public function translateFormulaToLocale(string $formula): string
33213317
);
33223318
}
33233319

3324-
/** @var ?array */
33253320
private static ?array $functionReplaceFromLocale;
33263321

3327-
/** @var ?array */
33283322
private static ?array $functionReplaceToExcel;
33293323

33303324
/**
@@ -5087,9 +5081,10 @@ private function processTokenStack(mixed $tokens, ?string $cellID = null, ?Cell
50875081
if ($cell === null || $pCellWorksheet === null) {
50885082
return $this->raiseFormulaError("undefined name '$token'");
50895083
}
5084+
$specifiedWorksheet = trim($matches[2], "'");
50905085

50915086
$this->debugLog->writeDebugLog('Evaluating Defined Name %s', $definedName);
5092-
$namedRange = DefinedName::resolveName($definedName, $pCellWorksheet);
5087+
$namedRange = DefinedName::resolveName($definedName, $pCellWorksheet, $specifiedWorksheet);
50935088
// If not Defined Name, try as Table.
50945089
if ($namedRange === null && $this->spreadsheet !== null) {
50955090
$table = $this->spreadsheet->getTableByName($definedName);
@@ -5114,7 +5109,7 @@ private function processTokenStack(mixed $tokens, ?string $cellID = null, ?Cell
51145109
return $this->raiseFormulaError("undefined name '$definedName'");
51155110
}
51165111

5117-
$result = $this->evaluateDefinedName($cell, $namedRange, $pCellWorksheet, $stack);
5112+
$result = $this->evaluateDefinedName($cell, $namedRange, $pCellWorksheet, $stack, $specifiedWorksheet !== '');
51185113
if (isset($storeKey)) {
51195114
$branchStore[$storeKey] = $result;
51205115
}
@@ -5593,10 +5588,10 @@ private function addCellReference(array $args, bool $passCellReference, array|st
55935588
return $args;
55945589
}
55955590

5596-
private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksheet $cellWorksheet, Stack $stack): mixed
5591+
private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksheet $cellWorksheet, Stack $stack, bool $ignoreScope = false): mixed
55975592
{
55985593
$definedNameScope = $namedRange->getScope();
5599-
if ($definedNameScope !== null && $definedNameScope !== $cellWorksheet) {
5594+
if ($definedNameScope !== null && $definedNameScope !== $cellWorksheet && !$ignoreScope) {
56005595
// The defined name isn't in our current scope, so #REF
56015596
$result = ExcelError::REF();
56025597
$stack->push('Error', $result, $namedRange->getName());

src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Helpers
1919
*/
2020
public static function isLeapYear(int|string $year): bool
2121
{
22+
$year = (int) $year;
23+
2224
return (($year % 4) === 0) && (($year % 100) !== 0) || (($year % 400) === 0);
2325
}
2426

src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static function fromString(null|array|string|int|bool|float $timeValue):
5252

5353
$arraySplit = preg_split('/[\/:\-\s]/', $timeValue) ?: [];
5454
if ((count($arraySplit) == 2 || count($arraySplit) == 3) && $arraySplit[0] > 24) {
55-
$arraySplit[0] = ($arraySplit[0] % 24);
55+
$arraySplit[0] = ((int) $arraySplit[0] % 24);
5656
$timeValue = implode(':', $arraySplit);
5757
}
5858

src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static function rate(
165165
$guess = ($guess === null) ? 0.1 : Functions::flattenSingleValue($guess);
166166

167167
try {
168-
$numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods);
168+
$numberOfPeriods = CashFlowValidations::validateFloat($numberOfPeriods);
169169
$payment = CashFlowValidations::validateFloat($payment);
170170
$presentValue = CashFlowValidations::validatePresentValue($presentValue);
171171
$futureValue = CashFlowValidations::validateFutureValue($futureValue);
@@ -193,7 +193,7 @@ public static function rate(
193193
return $close ? $rate : ExcelError::NAN();
194194
}
195195

196-
private static function rateNextGuess(float $rate, int $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type): string|float
196+
private static function rateNextGuess(float $rate, float $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type): string|float
197197
{
198198
if ($rate == 0.0) {
199199
return ExcelError::NAN();

src/PhpSpreadsheet/Cell/Cell.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class Cell implements Stringable
5050

5151
/**
5252
* The collection of cells that this cell belongs to (i.e. The Cell Collection for the parent Worksheet).
53-
*
54-
* @var ?Cells
5553
*/
5654
private ?Cells $parent;
5755

src/PhpSpreadsheet/Chart/Properties.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ abstract class Properties
105105

106106
protected bool $objectState = false; // used only for minor gridlines
107107

108-
/** @var ?float */
109108
protected ?float $glowSize = null;
110109

111110
protected ChartColor $glowColor;

src/PhpSpreadsheet/Helper/Html.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,13 +533,10 @@ class Html
533533
'yellowgreen' => '9acd32',
534534
];
535535

536-
/** @var ?string */
537536
private ?string $face = null;
538537

539-
/** @var ?string */
540538
private ?string $size = null;
541539

542-
/** @var ?string */
543540
private ?string $color = null;
544541

545542
private bool $bold = false;

src/PhpSpreadsheet/Reader/Csv/Delimiter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class Delimiter
1717

1818
protected int $numberLines = 0;
1919

20-
/** @var ?string */
2120
protected ?string $delimiter = null;
2221

2322
/**

src/PhpSpreadsheet/Reader/Html.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,10 @@ protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$r
627627
{
628628
foreach ($element->childNodes as $child) {
629629
if ($child instanceof DOMText) {
630-
$domText = (string) preg_replace('/\s+/u', ' ', trim($child->nodeValue ?? ''));
630+
$domText = (string) preg_replace('/\s+/', ' ', trim($child->nodeValue ?? ''));
631+
if ($domText === "\u{a0}") {
632+
$domText = '';
633+
}
631634
if (is_string($cellContent)) {
632635
// simply append the text if the cell content is a plain text string
633636
$cellContent .= $domText;

0 commit comments

Comments
 (0)