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 2d3a28ca..cd269be2 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2395,10 +2395,10 @@ class Calculation 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 @@ class Calculation { 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 bf11ceaf..b06cc4a7 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -355,7 +355,7 @@ class Functions 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 b6bd01cb..68aaf7b6 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1090,7 +1090,7 @@ class MathTrig 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 e4f866d9..65babc38 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -76,7 +76,7 @@ class Xml extends BaseReader // 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) {