Skip to content

Commit 8efb0fc

Browse files
authored
Merge branch 'master' into issue4241
2 parents 0e9719b + d4ffa3e commit 8efb0fc

File tree

553 files changed

+1329
-3746
lines changed

Some content is hidden

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

553 files changed

+1329
-3746
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
'ordered_imports' => true,
147147
'ordered_interfaces' => true,
148148
'ordered_traits' => true,
149+
'php_unit_attributes' => ['keep_annotations' => false],
149150
'php_unit_construct' => true,
150151
'php_unit_dedicate_assert' => true,
151152
'php_unit_dedicate_assert_internal_type' => true,

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2626
### Fixed
2727

2828
- Fix minor break handling drawings. [Issue #4241](https://github.com/PHPOffice/PhpSpreadsheet/issues/4241) [PR #4244](https://github.com/PHPOffice/PhpSpreadsheet/pull/4244)
29+
- Ignore cell formatting when the format is a single @. [Issue #4242](https://github.com/PHPOffice/PhpSpreadsheet/issues/4242) [PR #4243](https://github.com/PHPOffice/PhpSpreadsheet/pull/4243)
2930

3031
## 2024-11-22 - 3.5.0
3132

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This makes it easier to see exactly what is being tested when reviewing the PR.
4040
2. Tag subject must be the version number, eg: `1.2.3`
4141
3. Tag body must be a copy-paste of the changelog entries.
4242
3. Push the tag with `git push --tags`, GitHub Actions will create a GitHub release automatically, and the release details will automatically be sent to packagist.
43-
4. By default, Github remove markdown headings in the Release Notes. You can either edit to restore these, or, probably preferably, change the default comment character on your system - `git config core.commentChar ';'`.
43+
4. By default, Github removes markdown headings in the Release Notes. You can either edit to restore these, or, probably preferably, change the default comment character on your system - `git config core.commentChar ";"`.
4444

4545
> **Note:** Tagged releases are made from the `master` branch. Only in an emergency should a tagged release be made from the `release` branch. (i.e. cherry-picked hot-fixes.) However, there are 3 branches which have been updated to apply security patches, and those may be tagged if future security updates are needed.
4646
- release1291

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"phpcompatibility/php-compatibility": "^9.3",
9696
"phpstan/phpstan": "^1.1",
9797
"phpstan/phpstan-phpunit": "^1.0",
98-
"phpunit/phpunit": "^9.6 || ^10.5",
98+
"phpunit/phpunit": "^10.5",
9999
"squizlabs/php_codesniffer": "^3.7",
100100
"tecnickcom/tcpdf": "^6.5"
101101
},

docs/topics/recipes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,8 @@ style object:
12931293

12941294
```php
12951295
$spreadsheet->getActiveSheet()
1296-
->duplicateStyle(
1297-
$spreadsheet->getActiveSheet()->getStyle('B2'),
1296+
->duplicateConditionalStyle(
1297+
$spreadsheet->getActiveSheet()->getConditionalStyles('B2'),
12981298
'B3:B7'
12991299
);
13001300
```

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<coverage/>
44
<php>
55
<ini name="memory_limit" value="2048M"/>
6+
<ini name="error_reporting" value="E_ALL"/>
67
</php>
78
<testsuite name="PhpSpreadsheet Unit Test Suite">
89
<directory>./tests/PhpSpreadsheetTests</directory>

phpunit9.xml.dist

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/PhpSpreadsheet/Style/NumberFormat/Formatter.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Formatter extends BaseFormatter
1414
* Matches any @ symbol that isn't enclosed in quotes.
1515
*/
1616
private const SYMBOL_AT = '/@(?=(?:[^"]*"[^"]*")*[^"]*\Z)/miu';
17+
private const QUOTE_REPLACEMENT = "\u{fffe}"; // invalid Unicode character
1718

1819
/**
1920
* Matches any ; symbol that isn't enclosed in quotes, for a "section" split.
@@ -125,8 +126,23 @@ public static function toFormattedString($value, string $format, ?array $callBac
125126
}
126127
// For now we do not treat strings in sections, although section 4 of a format code affects strings
127128
// Process a single block format code containing @ for text substitution
128-
if (preg_match(self::SECTION_SPLIT, $format) === 0 && preg_match(self::SYMBOL_AT, $format) === 1) {
129-
return str_replace('"', '', preg_replace(self::SYMBOL_AT, (string) $value, $format) ?? '');
129+
$formatx = str_replace('\\"', self::QUOTE_REPLACEMENT, $format);
130+
if (preg_match(self::SECTION_SPLIT, $format) === 0 && preg_match(self::SYMBOL_AT, $formatx) === 1) {
131+
if (!str_contains($format, '"')) {
132+
return str_replace('@', $value, $format);
133+
}
134+
//escape any dollar signs on the string, so they are not replaced with an empty value
135+
$value = str_replace(
136+
['$', '"'],
137+
['\\$', self::QUOTE_REPLACEMENT],
138+
(string) $value
139+
);
140+
141+
return str_replace(
142+
['"', self::QUOTE_REPLACEMENT],
143+
['', '"'],
144+
preg_replace(self::SYMBOL_AT, $value, $formatx) ?? $value
145+
);
130146
}
131147

132148
// If we have a text value, return it "as is"

tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
class ArrayFormulaTest extends TestCase
1212
{
13-
/**
14-
* @dataProvider providerArrayFormulae
15-
*/
13+
#[\PHPUnit\Framework\Attributes\DataProvider('providerArrayFormulae')]
1614
public function testArrayFormula(string $formula, mixed $expectedResult): void
1715
{
1816
$result = Calculation::getInstance()->_calculateFormulaValue($formula);

tests/PhpSpreadsheetTests/Calculation/BinaryComparisonTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ protected function tearDown(): void
2424
Functions::setCompatibilityMode($this->compatibilityMode);
2525
}
2626

27-
/**
28-
* @dataProvider providerBinaryComparison
29-
*/
27+
#[\PHPUnit\Framework\Attributes\DataProvider('providerBinaryComparison')]
3028
public function testBinaryComparisonOperation(
3129
mixed $operand1,
3230
mixed $operand2,

0 commit comments

Comments
 (0)