From 883b9cfd56a7a638b983b98b7dcb4fcb1be8b091 Mon Sep 17 00:00:00 2001 From: Adrien Loison Date: Wed, 12 May 2021 22:59:11 +0200 Subject: [PATCH] Fix applyNumberFormat default value for XLSX When extract style attribute, a missing "applyNumberFormat" attribute would lead to a bool value being filled with `null`. This value would then be used for comparison (`if ($applyNumberFormat === false)`). This does not take into account the nullable aspect of the value. There is no reason to keep this value as nullable. If the attribute does not exist, then we should default to "false" (as in "Do not try to apply number format here"). --- src/Spout/Reader/XLSX/Manager/StyleManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spout/Reader/XLSX/Manager/StyleManager.php b/src/Spout/Reader/XLSX/Manager/StyleManager.php index d5db0d5..38aa7c8 100644 --- a/src/Spout/Reader/XLSX/Manager/StyleManager.php +++ b/src/Spout/Reader/XLSX/Manager/StyleManager.php @@ -175,7 +175,7 @@ class StyleManager $normalizedNumFmtId = ($numFmtId !== null) ? (int) $numFmtId : null; $applyNumberFormat = $xmlReader->getAttribute(self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT); - $normalizedApplyNumberFormat = ($applyNumberFormat !== null) ? (bool) $applyNumberFormat : null; + $normalizedApplyNumberFormat = ($applyNumberFormat !== null) ? (bool) $applyNumberFormat : false; $this->stylesAttributes[] = [ self::XML_ATTRIBUTE_NUM_FMT_ID => $normalizedNumFmtId,