From 5e531b4511de79403763bc3498c0d7e777af4f32 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 28 May 2021 22:11:43 +0200 Subject: [PATCH] Fix phpcs, phpstan and scrutinizer issues --- infra/LocaleGenerator.php | 1 - phpstan-baseline.neon | 5 ----- src/PhpSpreadsheet/Style/Font.php | 21 +++++++------------ .../LocaleGeneratorTest.php | 2 +- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/infra/LocaleGenerator.php b/infra/LocaleGenerator.php index b9862e9a..48f96ec8 100644 --- a/infra/LocaleGenerator.php +++ b/infra/LocaleGenerator.php @@ -341,6 +341,5 @@ class LocaleGenerator echo $message, PHP_EOL; - return; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b2da4ec1..4eed9863 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2235,11 +2235,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Document/Properties.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\DocumentGenerator\\:\\:getPhpSpreadsheetFunctionText\\(\\) has parameter \\$functionCall with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/DocumentGenerator.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\HashTable\\:\\:getIndexForHashCode\\(\\) should return int but returns int\\|string\\|false\\.$#" count: 1 diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 69979b8a..473fe1dc 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -19,7 +19,7 @@ class Font extends Supervisor protected $name = 'Calibri'; /** - * Font Size in points. + * Font Size. * * @var null|float */ @@ -249,27 +249,20 @@ class Font extends Supervisor /** * Set Size. * - * @param float $fontSizeInPoints + * @param float $pValue * * @return $this */ - public function setSize($fontSizeInPoints) + public function setSize($pValue) { - if (is_string($fontSizeInPoints) || is_int($fontSizeInPoints)) { - $fontSizeInPoints = (float) $fontSizeInPoints; // $pValue = 0 if given string is not numeric + if ($pValue == '') { + $pValue = 10; } - - // Size must be a positive floating point number - // ECMA-376-1:2016, part 1, chapter 18.4.11 sz (Font Size), p. 1536 - if (!is_float($fontSizeInPoints) || !($fontSizeInPoints > 0)) { - $fontSizeInPoints = 10.0; - } - if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['size' => $fontSizeInPoints]); + $styleArray = $this->getStyleArray(['size' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { - $this->size = $fontSizeInPoints; + $this->size = $pValue; } return $this; diff --git a/tests/PhpSpreadsheetTests/LocaleGeneratorTest.php b/tests/PhpSpreadsheetTests/LocaleGeneratorTest.php index dbec9d4a..e7429a25 100644 --- a/tests/PhpSpreadsheetTests/LocaleGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/LocaleGeneratorTest.php @@ -17,7 +17,7 @@ class LocaleGeneratorTest extends TestCase $phpSpreadsheetFunctions = $phpSpreadsheetFunctionsProperty->getValue(); $localeGenerator = new LocaleGenerator( - realpath(__DIR__ . '/../../src/PhpSpreadsheet/Calculation/locale/'), + (string) realpath(__DIR__ . '/../../src/PhpSpreadsheet/Calculation/locale/'), 'Translations.xlsx', $phpSpreadsheetFunctions );