Skip to content

Commit a02e4c2

Browse files
committed
Allow php-cs-fixer to Handle Implicit Backslashes
1 parent 4eefcce commit a02e4c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+109
-104
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
'standardize_not_equals' => true,
221221
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
222222
'strict_comparison' => false, // No, too dangerous to change that
223-
'string_implicit_backslashes' => false, // was escape_implicit_backslashes, too confusing
223+
'string_implicit_backslashes' => ['single_quoted' => 'unescape', 'double_quoted' => 'escape', 'heredoc' => 'escape'], // was escape_implicit_backslashes
224224
'strict_param' => false, // No, too dangerous to change that
225225
'string_length_to_empty' => true,
226226
'string_line_ending' => true,

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).
77

88
# TBD - 2.3.9
99

10+
### Changed
11+
12+
- Allow php-cs-fixer to Handle Implicit Backslashes.
13+
1014
### Fixed
1115

1216
- TEXT and TIMEVALUE functions. [Issue #4249](https://github.com/PHPOffice/PhpSpreadsheet/issues/4249) [PR #4354](https://github.com/PHPOffice/PhpSpreadsheet/pull/4354)

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"platform": {
1616
"php" : "8.1.99"
1717
},
18+
"process-timeout": 600,
1819
"sort-packages": true,
1920
"allow-plugins": {
2021
"dealerdirect/phpcodesniffer-composer-installer": true

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Calculation
5050
// Defined Names: Named Range of cells, or Named Formulae
5151
const CALCULATION_REGEXP_DEFINEDNAME = '((([^\s,!&%^\/\*\+<>=-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?([_\p{L}][_\p{L}\p{N}\.]*)';
5252
// Structured Reference (Fully Qualified and Unqualified)
53-
const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';
53+
const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';
5454
// Error
5555
const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?';
5656

src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function fromString(null|array|string|int|bool|float $dateValue):
4747
}
4848

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

src/PhpSpreadsheet/Calculation/Engine/Operands/StructuredReference.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class StructuredReference implements Operand, Stringable
2929
self::ITEM_SPECIFIER_TOTALS,
3030
];
3131

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

3434
private string $value;
3535

src/PhpSpreadsheet/Calculation/FormulaParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private function parseToTokens(): void
213213
// scientific notation check
214214
if (str_contains(self::OPERATORS_SN, $this->formula[$index])) {
215215
if (strlen($value) > 1) {
216-
if (preg_match('/^[1-9]{1}(\\.\\d+)?E{1}$/', $this->formula[$index]) != 0) {
216+
if (preg_match('/^[1-9]{1}(\.\d+)?E{1}$/', $this->formula[$index]) != 0) {
217217
$value .= $this->formula[$index];
218218
++$index;
219219

src/PhpSpreadsheet/Calculation/Functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public static function expandDefinedName(string $coordinate, Cell $cell): string
310310

311311
public static function trimTrailingRange(string $coordinate): string
312312
{
313-
return (string) preg_replace('/:[\\w\$]+$/', '', $coordinate);
313+
return (string) preg_replace('/:[\w\$]+$/', '', $coordinate);
314314
}
315315

316316
public static function trimSheetFromCellReference(string $coordinate): string

src/PhpSpreadsheet/Calculation/Internal/WildcardMatch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class WildcardMatch
66
{
77
private const SEARCH_SET = [
88
'~~', // convert double tilde to unprintable value
9-
'~\\*', // convert tilde backslash asterisk to [*] (matches literal asterisk in regexp)
10-
'\\*', // convert backslash asterisk to .* (matches string of any length in regexp)
11-
'~\\?', // convert tilde backslash question to [?] (matches literal question mark in regexp)
12-
'\\?', // convert backslash question to . (matches one character in regexp)
9+
'~\*', // convert tilde backslash asterisk to [*] (matches literal asterisk in regexp)
10+
'\*', // convert backslash asterisk to .* (matches string of any length in regexp)
11+
'~\?', // convert tilde backslash question to [?] (matches literal question mark in regexp)
12+
'\?', // convert backslash question to . (matches one character in regexp)
1313
"\x1c", // convert original double tilde to single tilde
1414
];
1515

src/PhpSpreadsheet/Calculation/TextData/Trim.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function nonPrintable(mixed $stringValue = '')
2525

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

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

3131
/**

0 commit comments

Comments
 (0)