Skip to content

Commit

Permalink
Allow php-cs-fixer to Handle Implicit Backslashes
Browse files Browse the repository at this point in the history
  • Loading branch information
oleibman committed Feb 11, 2025
1 parent 8f4c541 commit 7628348
Show file tree
Hide file tree
Showing 43 changed files with 115 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => false, // No, too dangerous to change that
'string_implicit_backslashes' => false, // was escape_implicit_backslashes, too confusing
'string_implicit_backslashes' => ['single_quoted' => 'unescape', 'double_quoted' => 'escape', 'heredoc' => 'escape'], // was escape_implicit_backslashes
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).

# TBD - 1.29.11

### Changed

- Allow php-cs-fixer to Handle Implicit Backslashes.

### Fixed

- TEXT and TIMEVALUE functions. [Issue #4249](https://github.com/PHPOffice/PhpSpreadsheet/issues/4249) [PR #4352](https://github.com/PHPOffice/PhpSpreadsheet/pull/4352)
Expand Down
6 changes: 3 additions & 3 deletions bin/findpolyfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ function findPolyfill(string $directory): int
// See issue #4215 - code which should have erred in unit test
// succeeded because a dev package required polyfills.
$retCode = 0;
$polyfill80 = 'FILTER_VALIDATE_BOOL\\b'
$polyfill80 = 'FILTER_VALIDATE_BOOL\b'
. '|fdiv[(]'
. '|preg_last_error_msg[(]'
. '|str_contains[(]'
. '|str_starts_with[(]'
. '|str_ends_with[(]'
. '|get_debug_type[(]'
. '|get_resource_id[(]';
$polyfill81 = 'MYSQLI_REFRESH_REPLICA\\b'
$polyfill81 = 'MYSQLI_REFRESH_REPLICA\b'
. '|fdiv[(]'
. '|array_is_list[(]'
. '|enum_exists[(]';
$polyfill = '/\\b(?:'
$polyfill = '/\b(?:'
. $polyfill80
. '|'
. $polyfill81
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"spreadsheet"
],
"config": {
"process-timeout": 600,
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand Down
10 changes: 5 additions & 5 deletions phpstan-conditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@
//];
// Erroneous analysis by Phpstan before PHP8 - mb_strlen does not return false
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:countCharacters\\(\\) should return int but returns int(<0, max>)?\\|false\\.$#',
'message' => '#^Method PhpOffice\\\PhpSpreadsheet\\\Shared\\\StringHelper\:\:countCharacters\(\) should return int but returns int(<0, max>)?\|false\.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Shared/StringHelper.php',
'count' => 1,
];
// New with Phpstan 1.9.2 for Php7 only
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array<int, mixed>\\|false given.$#',
'message' => '#^Parameter \#2 \.\.\.\$args of function array_merge expects array, array<int, mixed>\|false given.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Parameter \\#1 \\$input of function array_chunk expects array, array<int, float\\|int>\\|false given.$#',
'message' => '#^Parameter \#1 \$input of function array_chunk expects array, array<int, float\|int>\|false given.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Calculation/MathTrig/MatrixFunctions.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Parameter \\#2 \\$array of function array_map expects array, array<int, float|int>\\|false given.$#',
'message' => '#^Parameter \#2 \$array of function array_map expects array, array<int, float|int>\|false given.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Calculation/MathTrig/Random.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array<int, mixed>\\|false given.$#',
'message' => '#^Parameter \#2 \.\.\.\$args of function array_merge expects array, array<int, mixed>\|false given.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Calculation/TextData/Text.php',
'count' => 1,
];
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Calculation
// Defined Names: Named Range of cells, or Named Formulae
const CALCULATION_REGEXP_DEFINEDNAME = '((([^\s,!&%^\/\*\+<>=-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?([_\p{L}][_\p{L}\p{N}\.]*)';
// Structured Reference (Fully Qualified and Unqualified)
const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';
const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';
// Error
const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?';

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function fromString($dateValue)
}

// try to parse as date iff there is at least one digit
if (is_string($dateValue) && preg_match('/\\d/', $dateValue) !== 1) {
if (is_string($dateValue) && preg_match('/\d/', $dateValue) !== 1) {
return ExcelError::VALUE();
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function fromString($timeValue)
}

// try to parse as time iff there is at least one digit
if (is_string($timeValue) && preg_match('/\\d/', $timeValue) !== 1) {
if (is_string($timeValue) && preg_match('/\d/', $timeValue) !== 1) {
return ExcelError::VALUE();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class StructuredReference implements Operand
self::ITEM_SPECIFIER_TOTALS,
];

private const TABLE_REFERENCE = '/([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?:[^\]\[]+|(?R))*+\])/miu';
private const TABLE_REFERENCE = '/([\p{L}_\\\][\p{L}\p{N}\._]+)?(\[(?:[^\]\[]+|(?R))*+\])/miu';

private string $value;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/FormulaParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private function parseToTokens(): void
// scientific notation check
if (strpos(self::OPERATORS_SN, $this->formula[$index]) !== false) {
if (strlen($value) > 1) {
if (preg_match('/^[1-9]{1}(\\.\\d+)?E{1}$/', $this->formula[$index]) != 0) {
if (preg_match('/^[1-9]{1}(\.\d+)?E{1}$/', $this->formula[$index]) != 0) {
$value .= $this->formula[$index];
++$index;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ public static function expandDefinedName(string $coordinate, Cell $cell): string

public static function trimTrailingRange(string $coordinate): string
{
return (string) preg_replace('/:[\\w\$]+$/', '', $coordinate);
return (string) preg_replace('/:[\w\$]+$/', '', $coordinate);
}

public static function trimSheetFromCellReference(string $coordinate): string
Expand Down
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Calculation/Internal/WildcardMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class WildcardMatch
{
private const SEARCH_SET = [
'~~', // convert double tilde to unprintable value
'~\\*', // convert tilde backslash asterisk to [*] (matches literal asterisk in regexp)
'\\*', // convert backslash asterisk to .* (matches string of any length in regexp)
'~\\?', // convert tilde backslash question to [?] (matches literal question mark in regexp)
'\\?', // convert backslash question to . (matches one character in regexp)
'~\*', // convert tilde backslash asterisk to [*] (matches literal asterisk in regexp)
'\*', // convert backslash asterisk to .* (matches string of any length in regexp)
'~\?', // convert tilde backslash question to [?] (matches literal question mark in regexp)
'\?', // convert backslash question to . (matches one character in regexp)
"\x1c", // convert original double tilde to single tilde
];

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/TextData/Trim.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function nonPrintable($stringValue = '')

$stringValue = Helpers::extractString($stringValue);

return (string) preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
return (string) preg_replace('/[\x00-\x1f]/', '', "$stringValue");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Cell/DefaultValueBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function dataTypeForValue($value)
return DataType::TYPE_INLINE;
} elseif (is_string($value) && strlen($value) > 1 && $value[0] === '=') {
return DataType::TYPE_FORMULA;
} elseif (preg_match('/^[\+\-]?(\d+\\.?\d*|\d*\\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
} elseif (preg_match('/^[\+\-]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
$tValue = ltrim($value, '+-');
if (is_string($value) && strlen($tValue) > 1 && $tValue[0] === '0' && $tValue[1] !== '.') {
return DataType::TYPE_STRING;
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Document/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ private static function intOrFloatTimestamp($timestamp)
$timestamp = (float) $timestamp;
} else {
$timestamp = (string) preg_replace('/[.][0-9]*$/', '', $timestamp);
$timestamp = (string) preg_replace('/^(\\d{4})- (\\d)/', '$1-0$2', $timestamp);
$timestamp = (string) preg_replace('/^(\\d{4}-\\d{2})- (\\d)/', '$1-0$2', $timestamp);
$timestamp = (string) preg_replace('/^(\d{4})- (\d)/', '$1-0$2', $timestamp);
$timestamp = (string) preg_replace('/^(\d{4}-\d{2})- (\d)/', '$1-0$2', $timestamp);
$timestamp = (float) (new DateTime($timestamp))->format('U');
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Reader/Security/XmlScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class XmlScanner
{
private const ENCODING_PATTERN = '/encoding\\s*=\\s*(["\'])(.+?)\\1/s';
private const ENCODING_UTF7 = '/encoding\\s*=\\s*(["\'])UTF-7\\1/si';
private const ENCODING_PATTERN = '/encoding\s*=\s*(["\'])(.+?)\1/s';
private const ENCODING_UTF7 = '/encoding\s*=\s*(["\'])UTF-7\1/si';

/**
* String used to identify risky xml elements.
Expand Down Expand Up @@ -119,7 +119,7 @@ private function toUtf8($xml)
$charset = $this->findCharSet($xml);
$foundUtf7 = $charset === 'UTF-7';
if ($charset !== 'UTF-8') {
$testStart = '/^.{0,4}\\s*<?xml/s';
$testStart = '/^.{0,4}\s*<?xml/s';
$startWithXml1 = preg_match($testStart, $xml);
$xml = self::forceString(mb_convert_encoding($xml, 'UTF-8', $charset));
if ($startWithXml1 === 1 && preg_match($testStart, $xml) !== 1) {
Expand Down Expand Up @@ -168,7 +168,7 @@ public function scan($xml)
{
$this->disableEntityLoaderCheck();
// Don't rely purely on libxml_disable_entity_loader()
$pattern = '/\\0*' . implode('\\0*', /** @scrutinizer ignore-type */ str_split($this->pattern)) . '\\0*/';
$pattern = '/\0*' . implode('\0*', /** @scrutinizer ignore-type */ str_split($this->pattern)) . '\0*/';

$xml = "$xml";
if (preg_match($pattern, $xml)) {
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Slk.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private function styleSettings(string $rowDatum, array &$styleData, string &$fon
} elseif ($char == 'S') {
$styleData['fill']['fillType'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125;
} elseif ($char == 'M') {
if (preg_match('/M([1-9]\\d*)/', $styleSettings, $matches)) {
if (preg_match('/M([1-9]\d*)/', $styleSettings, $matches)) {
$fontStyle = $matches[1];
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ private function processPRecord(array $rowData, Spreadsheet &$spreadsheet): void

private function processPColors(string $rowDatum, array &$formatArray): void
{
if (preg_match('/L([1-9]\\d*)/', $rowDatum, $matches)) {
if (preg_match('/L([1-9]\d*)/', $rowDatum, $matches)) {
$fontColor = $matches[1] % 8;
$formatArray['font']['color']['argb'] = self::COLOR_ARRAY[$fontColor];
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function load(): void
$range = strtoupper((string) $dataValidation['sqref']);
$rangeSet = explode(' ', $range);
foreach ($rangeSet as $range) {
if (preg_match('/^[A-Z]{1,3}\\d{1,7}/', $range, $matches) === 1) {
if (preg_match('/^[A-Z]{1,3}\d{1,7}/', $range, $matches) === 1) {
// Ensure left/top row of range exists, thereby
// adjusting high row/column.
$this->worksheet->getCell($matches[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Shared/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static function convertIsoDate($value)
throw new Exception("Invalid string $value supplied for datatype Date");
}

if (preg_match('/^\\s*\\d?\\d:\\d\\d(:\\d\\d([.]\\d+)?)?\\s*(am|pm)?\\s*$/i', $value) == 1) {
if (preg_match('/^\s*\d?\d:\d\d(:\d\d([.]\d+)?)?\s*(am|pm)?\s*$/i', $value) == 1) {
$newValue = fmod($newValue, 1.0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Shared/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public static function getTrueTypeFontFileFromFont(FontStyle $font, bool $checkP
if (mb_strlen(self::$trueTypeFontPath) > 1 && mb_substr(self::$trueTypeFontPath, -1) !== '/' && mb_substr(self::$trueTypeFontPath, -1) !== '\\') {
$separator = DIRECTORY_SEPARATOR;
}
$fontFileAbsolute = preg_match('~^([A-Za-z]:)?[/\\\\]~', $fontFile) === 1;
$fontFileAbsolute = preg_match('~^([A-Za-z]:)?[/\\\]~', $fontFile) === 1;
if (!$fontFileAbsolute) {
$fontFile = self::$trueTypeFontPath . $separator . $fontFile;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static function format($value, string $format): string
// If the colon preceding minute had been quoted, as happens in
// Excel 2003 XML formats, m will not have been changed to i above.
// Change it now.
$format = (string) \preg_replace('/\\\\:m/', ':i', $format);
$format = (string) \preg_replace('/\\\:m/', ':i', $format);

return $dateObj->format($format);
}
Expand Down
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Style/NumberFormat/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ private static function splitFormatForSectionSelection(array $sections, $value):
// 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT]
$sectionCount = count($sections);
// Colour could be a named colour, or a numeric index entry in the colour-palette
$color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . '|color\\s*(\\d+))\\]/mui';
$cond_regex = '/\\[(>|>=|<|<=|=|<>)([+-]?\\d+([.]\\d+)?)\\]/';
$color_regex = '/\[(' . implode('|', Color::NAMED_COLORS) . '|color\s*(\d+))\]/mui';
$cond_regex = '/\[(>|>=|<|<=|=|<>)([+-]?\d+([.]\d+)?)\]/';
$colors = ['', '', '', '', ''];
$conditionOperations = ['', '', '', '', ''];
$conditionComparisonValues = [0, 0, 0, 0, 0];
Expand Down Expand Up @@ -156,7 +156,7 @@ public static function toFormattedString($value, $format, $callBack = null)
$format = (string) preg_replace('/^\[\$-[^\]]*\]/', '', $format);

$format = (string) preg_replace_callback(
'/(["])(?:(?=(\\\\?))\\2.)*?\\1/u',
'/(["])(?:(?=(\\\?))\2.)*?\1/u',
function ($matches) {
return str_replace('.', chr(0x00), $matches[0]);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function format($value, string $format): string
private static function getDecimal(string $value): string
{
$decimalPart = '0';
if (preg_match('/^\\d*[.](\\d*[1-9])0*$/', $value, $matches) === 1) {
if (preg_match('/^\d*[.](\d*[1-9])0*$/', $value, $matches) === 1) {
$decimalPart = $matches[1];
}

Expand Down
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class NumberFormatter
{
private const NUMBER_REGEX = '/(0+)(\\.?)(0*)/';
private const NUMBER_REGEX = '/(0+)(\.?)(0*)/';

private static function mergeComplexNumberFormatMasks(array $numbers, array $masks): array
{
Expand Down Expand Up @@ -223,11 +223,11 @@ public static function format($value, string $format): string
$paddingPlaceholder = (strpos($format, '?') !== false);

// Replace # or ? with 0
$format = self::pregReplace('/[\\#\?](?=(?:[^"]*"[^"]*")*[^"]*\Z)/', '0', $format);
$format = self::pregReplace('/[\#\?](?=(?:[^"]*"[^"]*")*[^"]*\Z)/', '0', $format);
// Remove locale code [$-###] for an LCID
$format = self::pregReplace('/\[\$\-.*\]/', '', $format);

$n = '/\\[[^\\]]+\\]/';
$n = '/\[[^\]]+\]/';
$m = self::pregReplace($n, '', $format);

// Some non-number strings are quoted, so we'll get rid of the quotes, likewise any positional * symbols
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/AutoFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function setRangeToMaxRow(): self
$this->evaluated = false;
if ($this->workSheet !== null) {
$thisrange = $this->range;
$range = (string) preg_replace('/\\d+$/', (string) $this->workSheet->getHighestRow(), $thisrange);
$range = (string) preg_replace('/\d+$/', (string) $this->workSheet->getHighestRow(), $thisrange);
if ($range !== $thisrange) {
$this->setRange($range);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/Drawing.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function setPath($path, $verifyFile = true, $zip = null)

$this->path = '';
// Check if a URL has been passed. https://stackoverflow.com/a/2058596/1252979
if (filter_var($path, FILTER_VALIDATE_URL) || (preg_match('/^([\\w\\s\\x00-\\x1f]+):/u', $path) && !preg_match('/^([\\w]+):/u', $path))) {
if (filter_var($path, FILTER_VALIDATE_URL) || (preg_match('/^([\w\s\x00-\x1f]+):/u', $path) && !preg_match('/^([\w]+):/u', $path))) {
if (!preg_match('/^(http|https|file|ftp|s3):/', $path)) {
throw new PhpSpreadsheetException('Invalid protocol for linked drawing');
}
Expand Down
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Worksheet/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public function setName(string $name): self
) {
throw new PhpSpreadsheetException('The table name can\'t be the same as a cell reference');
}
if (!preg_match('/^[\p{L}_\\\\]/iu', $name)) {
if (!preg_match('/^[\p{L}_\\\]/iu', $name)) {
throw new PhpSpreadsheetException('The table name must begin a name with a letter, an underscore character (_), or a backslash (\)');
}
if (!preg_match('/^[\p{L}_\\\\][\p{L}\p{M}0-9\._]+$/iu', $name)) {
if (!preg_match('/^[\p{L}_\\\][\p{L}\p{M}0-9\._]+$/iu', $name)) {
throw new PhpSpreadsheetException('The table name contains invalid characters');
}

Expand Down Expand Up @@ -324,7 +324,7 @@ public function setRangeToMaxRow(): self
{
if ($this->workSheet !== null) {
$thisrange = $this->range;
$range = (string) preg_replace('/\\d+$/', (string) $this->workSheet->getHighestRow(), $thisrange);
$range = (string) preg_replace('/\d+$/', (string) $this->workSheet->getHighestRow(), $thisrange);
if ($range !== $thisrange) {
$this->setRange($range);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/Validations.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function validateCellRange($cellRange): string
// Convert Column ranges like 'A:C' to 'A1:C1048576'
// or Row ranges like '1:3' to 'A1:XFD3'
$addressRange = (string) preg_replace(
['/^([A-Z]+):([A-Z]+)$/i', '/^(\\d+):(\\d+)$/'],
['/^([A-Z]+):([A-Z]+)$/i', '/^(\d+):(\d+)$/'],
[self::SETMAXROW, self::SETMAXCOL],
$addressRange
);
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ public function mergeCells($range, $behaviour = self::MERGE_CELL_CONTENT_EMPTY)
$range .= ":{$range}";
}

if (preg_match('/^([A-Z]+)(\\d+):([A-Z]+)(\\d+)$/', $range, $matches) !== 1) {
if (preg_match('/^([A-Z]+)(\d+):([A-Z]+)(\d+)$/', $range, $matches) !== 1) {
throw new Exception('Merge must be on a valid range of cells.');
}

Expand Down
Loading

0 comments on commit 7628348

Please sign in to comment.