From e0ed25d6b2e36e155e791e06b448eaca4094fc79 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Wed, 4 Jul 2018 16:55:33 +0200 Subject: [PATCH] Php Inspections (EA Extended): minor code tweaks (#579) --- src/PhpSpreadsheet/Calculation/Calculation.php | 8 ++++---- src/PhpSpreadsheet/Calculation/Functions.php | 2 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 2 +- src/PhpSpreadsheet/Reader/Xml.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 2d3a28ca8e..cd269be251 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2395,10 +2395,10 @@ public function _translateFormulaToLocale($formula) if (self::$functionReplaceToLocale === null) { self::$functionReplaceToLocale = []; - foreach (array_values(self::$localeFunctions) as $localeFunctionName) { + foreach (self::$localeFunctions as $localeFunctionName) { self::$functionReplaceToLocale[] = '$1' . trim($localeFunctionName) . '$2'; } - foreach (array_values(self::$localeBoolean) as $localeBoolean) { + foreach (self::$localeBoolean as $localeBoolean) { self::$functionReplaceToLocale[] = '$1' . trim($localeBoolean) . '$2'; } } @@ -2414,10 +2414,10 @@ public function _translateFormulaToEnglish($formula) { if (self::$functionReplaceFromLocale === null) { self::$functionReplaceFromLocale = []; - foreach (array_values(self::$localeFunctions) as $localeFunctionName) { + foreach (self::$localeFunctions as $localeFunctionName) { self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($localeFunctionName, '/') . '([\s]*\()/Ui'; } - foreach (array_values(self::$localeBoolean) as $excelBoolean) { + foreach (self::$localeBoolean as $excelBoolean) { self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($excelBoolean, '/') . '([^\w\.])/Ui'; } } diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index bf11ceaf7f..b06cc4a7d7 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -355,7 +355,7 @@ public static function isError($value = '') return false; } - return in_array($value, array_values(self::$errorCodes)); + return in_array($value, self::$errorCodes); } /** diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index b6bd01cb71..68aaf7b689 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1090,7 +1090,7 @@ function ($index) use ($cellReference) { if ($cellReference->getWorksheet()->cellExists($column . $row)) { //take this cell out if it contains the SUBTOTAL formula $isFormula = $cellReference->getWorksheet()->getCell($column . $row)->isFormula(); - $cellFormula = !preg_match('/^=.*\bSUBTOTAL\s*\(/', strtoupper($cellReference->getWorksheet()->getCell($column . $row)->getValue())); + $cellFormula = !preg_match('/^=.*\bSUBTOTAL\s*\(/i', $cellReference->getWorksheet()->getCell($column . $row)->getValue()); return !$isFormula || $cellFormula; } diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index e4f866d9ad..65babc38bf 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -76,7 +76,7 @@ public function canRead($pFilename) // Read sample data (first 2 KB will do) $data = fread($fileHandle, 2048); fclose($fileHandle); - $data = strtr($data, "'", '"'); // fix headers with single quote + $data = str_replace("'", '"', $data); // fix headers with single quote $valid = true; foreach ($signature as $match) {