diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index c976d4df9e..f33b4909f9 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -191,7 +191,7 @@ public function getFormattedValue(): string $currentCalendar = SharedDate::getExcelCalendar(); SharedDate::setExcelCalendar($this->getWorksheet()->getParent()?->getExcelCalendar()); $formattedValue = (string) NumberFormat::toFormattedString( - $this->getCalculatedValue(), + $this->getCalculatedValueString(), (string) $this->getStyle()->getNumberFormat()->getFormatCode(true) ); SharedDate::setExcelCalendar($currentCalendar); @@ -920,7 +920,7 @@ public function setXfIndex(int $indexValue): self * * @return $this */ - public function setFormulaAttributes(mixed $attributes): self + public function setFormulaAttributes(?array $attributes): self { $this->formulaAttributes = $attributes; diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 539129a196..e91eefb8a4 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -41,6 +41,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; +use Stringable; use Throwable; use XMLReader; use ZipArchive; @@ -240,7 +241,7 @@ public function listWorksheetInfo(string $filename): array 'totalColumns' => 0, ]; - $fileWorksheet = (string) $worksheets[(string) self::getArrayItem(self::getAttributes($eleSheet, $namespace), 'id')]; + $fileWorksheet = (string) $worksheets[self::getArrayItemString(self::getAttributes($eleSheet, $namespace), 'id')]; $fileWorksheetPath = str_starts_with($fileWorksheet, '/') ? substr($fileWorksheet, 1) : "$dir/$fileWorksheet"; $xml = new XMLReader(); @@ -569,6 +570,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $relType = "rel:Relationship[@Type='" . "$xmlNamespaceBase/styles" . "']"; + /** @var ?SimpleXMLElement */ $xpath = self::getArrayItem(self::xpathNoFalse($relsWorkbook, $relType)); if ($xpath === null) { @@ -604,6 +606,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet if ($xf['numFmtId']) { if (isset($numFmts)) { + /** @var ?SimpleXMLElement */ $tmpNumFmt = self::getArrayItem($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); if (isset($tmpNumFmt['formatCode'])) { @@ -649,6 +652,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $xf = self::getAttributes($xfTag); $numFmt = NumberFormat::FORMAT_GENERAL; if ($numFmts && $xf['numFmtId']) { + /** @var ?SimpleXMLElement */ $tmpNumFmt = self::getArrayItem($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); if (isset($tmpNumFmt['formatCode'])) { $numFmt = (string) $tmpNumFmt['formatCode']; @@ -692,6 +696,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet //. Namespaces::SHARED_STRINGS . "$xmlNamespaceBase/sharedStrings" . "']"; + /** @var ?SimpleXMLElement */ $xpath = self::getArrayItem($relsWorkbook->xpath($relType)); if ($xpath) { @@ -751,7 +756,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet continue; } - $sheetReferenceId = (string) self::getArrayItem(self::getAttributes($eleSheet, $xmlNamespaceBase), 'id'); + $sheetReferenceId = self::getArrayItemString(self::getAttributes($eleSheet, $xmlNamespaceBase), 'id'); if (isset($worksheets[$sheetReferenceId]) === false) { ++$countSkippedSheets; $mapSheetId[$oldSheetId] = null; @@ -1377,7 +1382,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $unparsedDrawings = []; $fileDrawing = null; foreach ($xmlSheetNS->drawing as $drawing) { - $drawingRelId = (string) self::getArrayItem(self::getAttributes($drawing, $xmlNamespaceBase), 'id'); + $drawingRelId = self::getArrayItemString(self::getAttributes($drawing, $xmlNamespaceBase), 'id'); $fileDrawing = $drawings[$drawingRelId]; $drawingFilename = dirname($fileDrawing) . '/_rels/' . basename($fileDrawing) . '.rels'; $relsDrawing = $this->loadZip($drawingFilename, Namespaces::RELATIONSHIPS); @@ -1431,9 +1436,9 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $outerShdw = $oneCellAnchor->pic->spPr->children(Namespaces::DRAWINGML)->effectLst->outerShdw; $objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); - $objDrawing->setName((string) self::getArrayItem(self::getAttributes($oneCellAnchor->pic->nvPicPr->cNvPr), 'name')); - $objDrawing->setDescription((string) self::getArrayItem(self::getAttributes($oneCellAnchor->pic->nvPicPr->cNvPr), 'descr')); - $embedImageKey = (string) self::getArrayItem( + $objDrawing->setName(self::getArrayItemString(self::getAttributes($oneCellAnchor->pic->nvPicPr->cNvPr), 'name')); + $objDrawing->setDescription(self::getArrayItemString(self::getAttributes($oneCellAnchor->pic->nvPicPr->cNvPr), 'descr')); + $embedImageKey = self::getArrayItemString( self::getAttributes($blip, $xmlNamespaceBase), 'embed' ); @@ -1444,7 +1449,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet false ); } else { - $linkImageKey = (string) self::getArrayItem( + $linkImageKey = self::getArrayItemString( $blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'link' ); @@ -1458,22 +1463,22 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $objDrawing->setOffsetX((int) Drawing::EMUToPixels($oneCellAnchor->from->colOff)); $objDrawing->setOffsetY(Drawing::EMUToPixels($oneCellAnchor->from->rowOff)); $objDrawing->setResizeProportional(false); - $objDrawing->setWidth(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($oneCellAnchor->ext), 'cx'))); - $objDrawing->setHeight(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($oneCellAnchor->ext), 'cy'))); + $objDrawing->setWidth(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($oneCellAnchor->ext), 'cx'))); + $objDrawing->setHeight(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($oneCellAnchor->ext), 'cy'))); if ($xfrm) { - $objDrawing->setRotation((int) Drawing::angleToDegrees(self::getArrayItem(self::getAttributes($xfrm), 'rot'))); + $objDrawing->setRotation((int) Drawing::angleToDegrees(self::getArrayItemIntOrSxml(self::getAttributes($xfrm), 'rot'))); $objDrawing->setFlipVertical((bool) self::getArrayItem(self::getAttributes($xfrm), 'flipV')); $objDrawing->setFlipHorizontal((bool) self::getArrayItem(self::getAttributes($xfrm), 'flipH')); } if ($outerShdw) { $shadow = $objDrawing->getShadow(); $shadow->setVisible(true); - $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($outerShdw), 'blurRad'))); - $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($outerShdw), 'dist'))); - $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItem(self::getAttributes($outerShdw), 'dir'))); - $shadow->setAlignment((string) self::getArrayItem(self::getAttributes($outerShdw), 'algn')); + $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($outerShdw), 'blurRad'))); + $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($outerShdw), 'dist'))); + $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItemIntOrSxml(self::getAttributes($outerShdw), 'dir'))); + $shadow->setAlignment(self::getArrayItemString(self::getAttributes($outerShdw), 'algn')); $clr = $outerShdw->srgbClr ?? $outerShdw->prstClr; - $shadow->getColor()->setRGB(self::getArrayItem(self::getAttributes($clr), 'val')); + $shadow->getColor()->setRGB(self::getArrayItemString(self::getAttributes($clr), 'val')); $shadow->setAlpha(self::getArrayItem(self::getAttributes($clr->alpha), 'val') / 1000); } @@ -1485,8 +1490,8 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $coordinates = Coordinate::stringFromColumnIndex(((int) $oneCellAnchor->from->col) + 1) . ($oneCellAnchor->from->row + 1); $offsetX = Drawing::EMUToPixels($oneCellAnchor->from->colOff); $offsetY = Drawing::EMUToPixels($oneCellAnchor->from->rowOff); - $width = Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($oneCellAnchor->ext), 'cx')); - $height = Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($oneCellAnchor->ext), 'cy')); + $width = Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($oneCellAnchor->ext), 'cx')); + $height = Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($oneCellAnchor->ext), 'cy')); $graphic = $oneCellAnchor->graphicFrame->children(Namespaces::DRAWINGML)->graphic; /** @var SimpleXMLElement $chartRef */ @@ -1520,9 +1525,9 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet if (isset($editAs, $editAs['editAs'])) { $objDrawing->setEditAs($editAs['editAs']); } - $objDrawing->setName((string) self::getArrayItem(self::getAttributes($twoCellAnchor->pic->nvPicPr->cNvPr), 'name')); - $objDrawing->setDescription((string) self::getArrayItem(self::getAttributes($twoCellAnchor->pic->nvPicPr->cNvPr), 'descr')); - $embedImageKey = (string) self::getArrayItem( + $objDrawing->setName((string) self::getArrayItemString(self::getAttributes($twoCellAnchor->pic->nvPicPr->cNvPr), 'name')); + $objDrawing->setDescription(self::getArrayItemString(self::getAttributes($twoCellAnchor->pic->nvPicPr->cNvPr), 'descr')); + $embedImageKey = self::getArrayItemString( self::getAttributes($blip, $xmlNamespaceBase), 'embed' ); @@ -1533,7 +1538,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet false ); } else { - $linkImageKey = (string) self::getArrayItem( + $linkImageKey = self::getArrayItemString( $blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'link' ); @@ -1555,21 +1560,21 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $objDrawing->setResizeProportional(false); if ($xfrm) { - $objDrawing->setWidth(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($xfrm->ext), 'cx'))); - $objDrawing->setHeight(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($xfrm->ext), 'cy'))); - $objDrawing->setRotation(Drawing::angleToDegrees(self::getArrayItem(self::getAttributes($xfrm), 'rot'))); + $objDrawing->setWidth(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($xfrm->ext), 'cx'))); + $objDrawing->setHeight(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($xfrm->ext), 'cy'))); + $objDrawing->setRotation(Drawing::angleToDegrees(self::getArrayItemIntOrSxml(self::getAttributes($xfrm), 'rot'))); $objDrawing->setFlipVertical((bool) self::getArrayItem(self::getAttributes($xfrm), 'flipV')); $objDrawing->setFlipHorizontal((bool) self::getArrayItem(self::getAttributes($xfrm), 'flipH')); } if ($outerShdw) { $shadow = $objDrawing->getShadow(); $shadow->setVisible(true); - $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($outerShdw), 'blurRad'))); - $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItem(self::getAttributes($outerShdw), 'dist'))); - $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItem(self::getAttributes($outerShdw), 'dir'))); - $shadow->setAlignment((string) self::getArrayItem(self::getAttributes($outerShdw), 'algn')); + $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($outerShdw), 'blurRad'))); + $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItemIntOrSxml(self::getAttributes($outerShdw), 'dist'))); + $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItemIntOrSxml(self::getAttributes($outerShdw), 'dir'))); + $shadow->setAlignment(self::getArrayItemString(self::getAttributes($outerShdw), 'algn')); $clr = $outerShdw->srgbClr ?? $outerShdw->prstClr; - $shadow->getColor()->setRGB(self::getArrayItem(self::getAttributes($clr), 'val')); + $shadow->getColor()->setRGB(self::getArrayItemString(self::getAttributes($clr), 'val')); $shadow->setAlpha(self::getArrayItem(self::getAttributes($clr->alpha), 'val') / 1000); } @@ -1607,8 +1612,8 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet /** @var SimpleXMLElement $chartRef */ $chartRef = $graphic->graphicData->children(Namespaces::CHART)->chart; $thisChart = (string) self::getAttributes($chartRef, $xmlNamespaceBase); - $width = Drawing::EMUToPixels((int) self::getArrayItem(self::getAttributes($absoluteAnchor->ext), 'cx')[0]); - $height = Drawing::EMUToPixels((int) self::getArrayItem(self::getAttributes($absoluteAnchor->ext), 'cy')[0]); + $width = Drawing::EMUToPixels((int) self::getArrayItemString(self::getAttributes($absoluteAnchor->ext), 'cx')[0]); + $height = Drawing::EMUToPixels((int) self::getArrayItemString(self::getAttributes($absoluteAnchor->ext), 'cy')[0]); $chartDetails[$docSheet->getTitle() . '!' . $thisChart] = [ 'fromCoordinate' => 'A1', @@ -1641,7 +1646,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet } if ($xmlSheet->legacyDrawing && !$this->readDataOnly) { foreach ($xmlSheet->legacyDrawing as $drawing) { - $drawingRelId = (string) self::getArrayItem(self::getAttributes($drawing, $xmlNamespaceBase), 'id'); + $drawingRelId = self::getArrayItemString(self::getAttributes($drawing, $xmlNamespaceBase), 'id'); if (isset($vmlDrawingContents[$drawingRelId])) { if (self::onlyNoteVml($vmlDrawingContents[$drawingRelId]) === false) { $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['legacyDrawing'] = $vmlDrawingContents[$drawingRelId]; @@ -2012,6 +2017,20 @@ private static function getArrayItem(null|array|bool|SimpleXMLElement $array, in return ($array === null || is_bool($array)) ? null : ($array[$key] ?? null); } + private static function getArrayItemString(null|array|bool|SimpleXMLElement $array, int|string $key = 0): string + { + $retVal = self::getArrayItem($array, $key); + + return ($retVal === null || is_scalar($retVal) || $retVal instanceof Stringable) ? ((string) $retVal) : ''; + } + + private static function getArrayItemIntOrSxml(null|array|bool|SimpleXMLElement $array, int|string $key = 0): int|SimpleXMLElement + { + $retVal = self::getArrayItem($array, $key); + + return (is_int($retVal) || $retVal instanceof SimpleXMLElement) ? $retVal : 0; + } + private static function dirAdd(null|SimpleXMLElement|string $base, null|SimpleXMLElement|string $add): string { $base = (string) $base; @@ -2076,7 +2095,7 @@ private function readHyperLinkDrawing(\PhpOffice\PhpSpreadsheet\Worksheet\Drawin $hlinkId = (string) self::getAttributes($hlinkClick, Namespaces::SCHEMA_OFFICE_DOCUMENT)['id']; $hyperlink = new Hyperlink( $hyperlinks[$hlinkId], - (string) self::getArrayItem(self::getAttributes($cellAnchor->pic->nvPicPr->cNvPr), 'name') + self::getArrayItemString(self::getAttributes($cellAnchor->pic->nvPicPr->cNvPr), 'name') ); $objDrawing->setHyperlink($hyperlink); } @@ -2242,7 +2261,7 @@ private function readBackgroundImage( string $relsName ): void { if ($xmlSheet && $xmlSheet->picture) { - $id = (string) self::getArrayItem(self::getAttributes($xmlSheet->picture, Namespaces::SCHEMA_OFFICE_DOCUMENT), 'id'); + $id = (string) self::getArrayItemString(self::getAttributes($xmlSheet->picture, Namespaces::SCHEMA_OFFICE_DOCUMENT), 'id'); $rels = $this->loadZip($relsName); foreach ($rels->Relationship as $rel) { $attrs = $rel->attributes() ?? []; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index e82d7ccd9b..9e610f234f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -60,8 +60,8 @@ public function testTooMuchPrecision(mixed $expectedResult, float|int|string $va $sheet = $this->getSheet(); $sheet->getCell('E1')->setValue($value); $sheet->getCell('E2')->setValue("=TRUNC(E1,$digits)"); - $result = $sheet->getCell('E2')->getCalculatedValue(); - self::assertSame($expectedResult, (string) $result); + $result = $sheet->getCell('E2')->getCalculatedValueString(); + self::assertSame($expectedResult, $result); } public static function providerTooMuchPrecision(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php index be3cbd1ed6..3a5f33cff5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -30,6 +30,7 @@ public function testCONCATENATE(mixed $expectedResult, mixed ...$args): void $finalArg .= 'A3'; $sheet->getCell('A3')->setValue(str_repeat('Ԁ', DataType::MAX_STRING_LENGTH - 5)); } else { + self::assertTrue($arg === null || is_scalar($arg)); $finalArg .= '"' . (string) $arg . '"'; } } diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormula2Test.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormula2Test.php index 58e1eebd6d..6ea143565f 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormula2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormula2Test.php @@ -26,7 +26,7 @@ public function testArrayFormulaReader( $cell = $worksheet->getCell($cellAddress); self::assertSame(DataType::TYPE_FORMULA, $cell->getDataType()); self::assertSame(['t' => 'array', 'ref' => $expectedRange], $cell->getFormulaAttributes()); - self::assertSame($expectedFormula, strtoupper($cell->getValue())); + self::assertSame($expectedFormula, strtoupper($cell->getValueString())); Calculation::getInstance($spreadsheet)->setInstanceArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY); $worksheet->calculateArrays(); $cell = $worksheet->getCell($cellAddress); diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php index 80817633a2..f0e9599cc7 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php @@ -30,7 +30,7 @@ public function testArrayFormulaReader( } else { self::assertEmpty($cell->getFormulaAttributes()); } - self::assertSame($expectedFormula, strtoupper($cell->getValue())); + self::assertSame($expectedFormula, strtoupper($cell->getValueString())); Calculation::getInstance($spreadsheet)->setInstanceArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY); $worksheet->calculateArrays(); $cell = $worksheet->getCell($cellAddress); diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php index 0c4cd1d453..726b42ba3f 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php @@ -26,7 +26,7 @@ public function testArrayFormulaReader( $cell = $worksheet->getCell($cellAddress); self::assertSame(DataType::TYPE_FORMULA, $cell->getDataType()); self::assertSame(['t' => 'array', 'ref' => $expectedRange], $cell->getFormulaAttributes()); - self::assertSame($expectedFormula, strtoupper($cell->getValue())); + self::assertSame($expectedFormula, strtoupper($cell->getValueString())); Calculation::getInstance($spreadsheet)->setInstanceArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY); $worksheet->calculateArrays(); $cell = $worksheet->getCell($cellAddress); diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/ArrayFormulaTest.php index 6ba32aa334..9bc9621118 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/ArrayFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/ArrayFormulaTest.php @@ -17,7 +17,7 @@ public function testArrayFormulaReader(): void self::assertSame(DataType::TYPE_FORMULA, $sheet->getCell('B1')->getDataType()); self::assertSame(['t' => 'array', 'ref' => 'B1:B3'], $sheet->getCell('B1')->getFormulaAttributes()); - self::assertSame('=CONCATENATE(A1:A3,"-",C1:C3)', strtoupper($sheet->getCell('B1')->getValue())); + self::assertSame('=CONCATENATE(A1:A3,"-",C1:C3)', strtoupper($sheet->getCell('B1')->getValueString())); self::assertSame('a-1', $sheet->getCell('B1')->getOldCalculatedValue()); self::assertSame('b-2', $sheet->getCell('B2')->getValue()); self::assertSame('c-3', $sheet->getCell('B3')->getValue()); diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFunctions2Test.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFunctions2Test.php index ab3a54a4d3..c41a176fb8 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFunctions2Test.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFunctions2Test.php @@ -268,7 +268,9 @@ public function testManyArraysOutput(): void { $json = file_get_contents('tests/data/Writer/XLSX/ArrayFunctions2.json'); self::assertNotFalse($json); - $this->trn = json_decode($json, true); + $trn = json_decode($json, true); + self::assertIsArray($trn); + $this->trn = $trn; $spreadsheet = new Spreadsheet(); Calculation::getInstance($spreadsheet)->setInstanceArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);