Skip to content

Commit 5cc5a49

Browse files
authored
Merge branch 'master' into issue4860
2 parents 95ffbf0 + 7cc6e4e commit 5cc5a49

9 files changed

Lines changed: 149 additions & 55 deletions

File tree

composer.lock

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

docs/topics/memory_saving.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,24 @@ details, but here are a few suggestions that should get you started.
5353

5454
### APCu
5555

56-
Require the packages into your project:
56+
Require Symfony Cache in your project:
5757

5858
```sh
59-
composer require cache/simple-cache-bridge cache/apcu-adapter
59+
composer require symfony/cache
6060
```
6161

62+
You must also install and enable the APCu PHP extension for your environment.
63+
6264
Configure PhpSpreadsheet with something like:
6365

6466
```php
65-
$pool = new \Cache\Adapter\Apcu\ApcuCachePool();
66-
$simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);
67+
use Symfony\Component\Cache\Adapter\ApcuAdapter;
68+
use Symfony\Component\Cache\Psr16Cache;
6769

68-
\PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);
70+
$apcuAdapter = new ApcuAdapter();
71+
$cache = new Psr16Cache($apcuAdapter);
72+
73+
\PhpOffice\PhpSpreadsheet\Settings::setCache($cache);
6974
```
7075

7176
### Redis

samples/Engineering/Convert-Online.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
$toUnit = $post['toUnit'];
8787
if (!is_numeric($quantity)) {
8888
$helper->log('Quantity is not numeric');
89-
} elseif (isset($units[$post['category']][$fromUnit], $units[$post['category']][$toUnit])) {
89+
} elseif (isset($post['category'], $units[$post['category']][$fromUnit], $units[$post['category']][$toUnit])) {
9090
/** @var float|string */
9191
$result = ConvertUOM::CONVERT($quantity, $fromUnit, $toUnit);
9292

src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ public static function compareKeys(): bool
192192
$retVal = true;
193193
$array = array_merge(array_keys(self::SINGLE_OPERATORS), array_keys(self::RANGE_OPERATORS));
194194
foreach ($array as $value) {
195-
$retVal = $retVal && in_array($value, self::MAGIC_OPERATIONS, true);
195+
// PhpStan is correct about next statement, but we want to test anyhow
196+
$retVal = $retVal && in_array($value, self::MAGIC_OPERATIONS, true); // @phpstan-ignore-line
196197
}
197198

198199
return $retVal;

src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ public static function compareKeys(): bool
169169
$retVal = true;
170170
$array = array_keys(self::OPERATORS);
171171
foreach ($array as $value) {
172-
$retVal = $retVal && in_array($value, self::MAGIC_OPERATIONS, true);
172+
// PhpStan is correct about next statement, but we want to test anyhow
173+
$retVal = $retVal && in_array($value, self::MAGIC_OPERATIONS, true); // @phpstan-ignore-line
173174
}
174175

175176
return $retVal;

src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,13 @@ private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell
15761576
{
15771577
$attributes = $cell->getFormulaAttributes() ?? [];
15781578
$coordinate = $cell->getCoordinate();
1579-
$calculatedValue = $this->getParentWriter()->getPreCalculateFormulas() ? $cell->getCalculatedValue() : $cellValue;
1579+
$preCalc = $this->getParentWriter()->getPreCalculateFormulas();
1580+
// When pre-calc is off we have no calculated value to infer the cell type from. The
1581+
// previous fall-back of $cellValue (the formula source) made every formula cell write
1582+
// t="str" because the source is always a string — misleading for formulas that resolve
1583+
// to numbers/booleans. Leave $calculatedValue/$calculatedValueString null so the
1584+
// type-inference branches below are skipped and no t attribute is written.
1585+
$calculatedValue = $preCalc ? $cell->getCalculatedValue() : null;
15801586
if ($calculatedValue === ExcelError::SPILL()) {
15811587
$objWriter->writeAttribute('t', 'e');
15821588
//$objWriter->writeAttribute('cm', '1'); // already added
@@ -1592,7 +1598,10 @@ private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell
15921598

15931599
return;
15941600
}
1595-
$calculatedValueString = $this->getParentWriter()->getPreCalculateFormulas() ? $cell->getCalculatedValueString() : $cellValue;
1601+
// Empty string (not null) so str_starts_with($calculatedValueString, '#') below stays
1602+
// type-correct when pre-calc is off; the surrounding writeElementIf condition guards
1603+
// against actually emitting <v> when there is no calculated value.
1604+
$calculatedValueString = $preCalc ? $cell->getCalculatedValueString() : '';
15961605
$result = $calculatedValue;
15971606
while (is_array($result)) {
15981607
$result = array_shift($result);

tests/PhpSpreadsheetTests/Chart/ChartCloneTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ public function testCloneSheetWithTrendLines(): void
154154
self::assertCount(1, $oldLabels);
155155
self::assertCount(3, $oldLabels[0]->getTrendLines());
156156

157-
$plotGroup = $chart->getPlotArea()?->getPlotGroup();
158-
self::assertNotNull($plotGroup);
157+
$plotGroup = $chart->getPlotArea()->getPlotGroup();
159158
self::assertCount(1, $plotGroup);
160159
$plotLabels = $plotGroup[0]->getPlotLabels();
161160
self::assertCount(1, $plotLabels);

0 commit comments

Comments
 (0)