Skip to content

Commit 4577f61

Browse files
authored
Merge branch 'master' into issue3995
2 parents 148165c + d38b7cb commit 4577f61

File tree

20 files changed

+225
-183
lines changed

20 files changed

+225
-183
lines changed

src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php

Lines changed: 158 additions & 158 deletions
Large diffs are not rendered by default.

src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static function calculateArabic(array $roman, int &$sum = 0, int $subtra
5353
* Excel Function:
5454
* ARABIC(text)
5555
*
56-
* @param mixed $roman Should be a string, or can be an array of strings
56+
* @param string|string[] $roman Should be a string, or can be an array of strings
5757
*
5858
* @return array|int|string the arabic numberal contrived from the roman numeral
5959
* If an array of numbers is passed as the argument, then the returned result will also be an array

src/PhpSpreadsheet/Calculation/TextData/Format.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static function DOLLAR(mixed $value = 0, mixed $decimals = 2)
5656
if ($value < 0) {
5757
$round = 0 - $round;
5858
}
59+
/** @var float|int|string */
5960
$value = MathTrig\Round::multiple($value, $round);
6061
}
6162
$mask = "{$mask};-{$mask}";
@@ -129,6 +130,7 @@ public static function TEXTFORMAT(mixed $value, mixed $format): array|string
129130
if (!is_numeric($value) && Date::isDateTimeFormatCode($format)) {
130131
$value1 = DateTimeExcel\DateValue::fromString($value);
131132
$value2 = DateTimeExcel\TimeValue::fromString($value);
133+
/** @var float|int|string */
132134
$value = (is_numeric($value1) && is_numeric($value2)) ? ($value1 + $value2) : (is_numeric($value1) ? $value2 : $value1);
133135
}
134136

src/PhpSpreadsheet/Cell/Cell.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ public function getValue(): mixed
175175
return $this->value;
176176
}
177177

178+
public function getValueString(): string
179+
{
180+
$value = $this->value;
181+
182+
return ($value === '' || is_scalar($value) || $value instanceof Stringable) ? "$value" : '';
183+
}
184+
178185
/**
179186
* Get cell value with formatting.
180187
*/
@@ -336,6 +343,16 @@ private function convertDateTimeInt(mixed $result): mixed
336343
return $result;
337344
}
338345

346+
/**
347+
* Get calculated cell value converted to string.
348+
*/
349+
public function getCalculatedValueString(): string
350+
{
351+
$value = $this->getCalculatedValue();
352+
353+
return ($value === '' || is_scalar($value) || $value instanceof Stringable) ? "$value" : '';
354+
}
355+
339356
/**
340357
* Get calculated cell value.
341358
*

src/PhpSpreadsheet/Shared/Font.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,10 @@ private static function findFontFile(string $startDirectory, string $desiredFont
695695
$it,
696696
RecursiveIteratorIterator::LEAVES_ONLY,
697697
RecursiveIteratorIterator::CATCH_GET_CHILD
698-
) as $file
698+
) as $filex
699699
) {
700+
/** @var string */
701+
$file = $filex;
700702
if (basename($file) === $desiredFont) {
701703
$fontPath = $file;
702704

src/PhpSpreadsheet/Shared/StringHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public static function formatNumber(float|int|string|null $numericValue): string
346346
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3.
347347
*
348348
* @param string $textValue UTF-8 encoded string
349-
* @param mixed[] $arrcRuns Details of rich text runs in $value
349+
* @param array<int, array{strlen: int, fontidx: int}> $arrcRuns Details of rich text runs in $value
350350
*/
351351
public static function UTF8toBIFF8UnicodeShort(string $textValue, array $arrcRuns = []): string
352352
{

src/PhpSpreadsheet/Style/NumberFormat.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Style;
44

5+
use PhpOffice\PhpSpreadsheet\RichText\RichText;
6+
57
class NumberFormat extends Supervisor
68
{
79
// Pre-defined formats
@@ -453,7 +455,7 @@ public function getHashCode(): string
453455
/**
454456
* Convert a value in a pre-defined format to a PHP string.
455457
*
456-
* @param mixed $value Value to format
458+
* @param null|bool|float|int|RichText|string $value Value to format
457459
* @param string $format Format code: see = self::FORMAT_* for predefined values;
458460
* or can be any valid MS Excel custom format string
459461
* @param ?array $callBack Callback function for additional formatting of string

src/PhpSpreadsheet/Style/NumberFormat/Formatter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private static function splitFormatComparison(
4242
};
4343
}
4444

45+
/** @param float|int|string $value value to be formatted */
4546
private static function splitFormatForSectionSelection(array $sections, mixed $value): array
4647
{
4748
// Extract the relevant section depending on whether number is positive, negative, or zero?

src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class FractionFormatter extends BaseFormatter
88
{
9+
/** @param null|bool|float|int|string $value value to be formatted */
910
public static function format(mixed $value, string $format): string
1011
{
1112
$format = self::stripQuotes($format);

src/PhpSpreadsheet/Worksheet/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private function updateStructuredReferencesInCells(Worksheet $worksheet, string
178178
foreach ($worksheet->getCoordinates(false) as $coordinate) {
179179
$cell = $worksheet->getCell($coordinate);
180180
if ($cell->getDataType() === DataType::TYPE_FORMULA) {
181-
$formula = $cell->getValue();
181+
$formula = $cell->getValueString();
182182
if (preg_match($pattern, $formula) === 1) {
183183
$formula = preg_replace($pattern, "{$newName}[", $formula);
184184
$cell->setValueExplicit($formula, DataType::TYPE_FORMULA);

0 commit comments

Comments
 (0)