Skip to content

Commit ac9a0fe

Browse files
authored
Merge branch 'master' into issue1275
2 parents 0d236eb + d8ad4b0 commit ac9a0fe

File tree

109 files changed

+941
-404
lines changed

Some content is hidden

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

109 files changed

+941
-404
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787

8888
# This is non-ideal because it only checks for the last commit of the PR, not all of them, but better than nothing
8989
- name: Check PHPDoc types
90-
run: ./bin/check-phpdoc-types
90+
run: ./bin/check-phpdoc-types.php
9191

9292
php-cs-fixer:
9393
runs-on: ubuntu-latest

.php-cs-fixer.dist.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22

33
$finder = PhpCsFixer\Finder::create()
4-
->exclude('vendor')
4+
->exclude(['vendor', 'docs', '.git', '.github'])
55
->notPath('src/PhpSpreadsheet/Writer/ZipStream3.php')
6-
->name('/(\.php|^generate-document|^generate-locales|^check-phpdoc-types)$/')
76
->in(__DIR__);
87

98
$config = new PhpCsFixer\Config();

.phpcs.xml.dist

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
<file>src</file>
77
<file>tests</file>
88
<file>infra</file>
9-
<file>bin/generate-document</file>
10-
<file>bin/generate-locales</file>
11-
<file>bin/check-phpdoc-types</file>
12-
13-
<exclude-pattern>samples/Header.php</exclude-pattern>
14-
<exclude-pattern>*/tests/Core/*/*Test\.(inc|css|js)$</exclude-pattern>
9+
<file>bin</file>
1510

1611
<arg name="report-width" value="200"/>
1712
<arg name="parallel" value="80"/>

CHANGELOG.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com)
66
and this project adheres to [Semantic Versioning](https://semver.org).
77

8-
## TBD - 4.2.0
8+
## TBD - 4.3.0
99

1010
### Added
1111

12-
- Add ability to add custom functions to Calculation. [PR #4390](https://github.com/PHPOffice/PhpSpreadsheet/pull/4390)
13-
- Add FormulaRange to IgnoredErrors. [PR #4393](https://github.com/PHPOffice/PhpSpreadsheet/pull/4393)
14-
- TextGrid improvements. [PR #4418](https://github.com/PHPOffice/PhpSpreadsheet/pull/4418)
15-
- Permit read to class which extends Spreadsheet. [Discussion #4402](https://github.com/PHPOffice/PhpSpreadsheet/discussions/4402) [PR #4404](https://github.com/PHPOffice/PhpSpreadsheet/pull/4404)
16-
- Conditional and table formatting support for html writer [PR #4412](https://github.com/PHPOffice/PhpSpreadsheet/pull/4412)
12+
- Nothing yet.
1713

1814
### Removed
1915

2016
- Nothing yet.
2117

2218
### Changed
2319

24-
- Phpstan Version 2. [PR #4384](https://github.com/PHPOffice/PhpSpreadsheet/pull/4384)
25-
- Start migration to Phpstan level 9. [PR #4396](https://github.com/PHPOffice/PhpSpreadsheet/pull/4396)
26-
- Calculation locale logic moved to separate class. [PR #4398](https://github.com/PHPOffice/PhpSpreadsheet/pull/4398)
27-
- TREND_POLYNOMIAL_* and TREND_BEST_FIT do not work, and are changed to throw Exceptions if attempted. (TREND_BEST_FIT_NO_POLY works.) An attempt to use an unknown trend type will now also throw an exception. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
28-
- Month parameter of DATE function will now return VALUE if an ordinal string (e.g. '3rd') is used, but will accept bool or null. [PR #4420](https://github.com/PHPOffice/PhpSpreadsheet/pull/4420)
20+
- Nothing yet.
2921

3022
### Moved
3123

@@ -37,6 +29,28 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3729

3830
### Fixed
3931

32+
- Nothing yet.
33+
34+
## 2025-04-16 - 4.2.0
35+
36+
### Added
37+
38+
- Add ability to add custom functions to Calculation. [PR #4390](https://github.com/PHPOffice/PhpSpreadsheet/pull/4390)
39+
- Add FormulaRange to IgnoredErrors. [PR #4393](https://github.com/PHPOffice/PhpSpreadsheet/pull/4393)
40+
- TextGrid improvements. [PR #4418](https://github.com/PHPOffice/PhpSpreadsheet/pull/4418)
41+
- Permit read to class which extends Spreadsheet. [Discussion #4402](https://github.com/PHPOffice/PhpSpreadsheet/discussions/4402) [PR #4404](https://github.com/PHPOffice/PhpSpreadsheet/pull/4404)
42+
- Conditional and table formatting support for html writer [PR #4412](https://github.com/PHPOffice/PhpSpreadsheet/pull/4412)
43+
44+
### Changed
45+
46+
- Phpstan Version 2. [PR #4384](https://github.com/PHPOffice/PhpSpreadsheet/pull/4384)
47+
- Start migration to Phpstan level 9. [PR #4396](https://github.com/PHPOffice/PhpSpreadsheet/pull/4396)
48+
- Calculation locale logic moved to separate class. [PR #4398](https://github.com/PHPOffice/PhpSpreadsheet/pull/4398)
49+
- TREND_POLYNOMIAL_* and TREND_BEST_FIT do not work, and are changed to throw Exceptions if attempted. (TREND_BEST_FIT_NO_POLY works.) An attempt to use an unknown trend type will now also throw an exception. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
50+
- Month parameter of DATE function will now return VALUE if an ordinal string (e.g. '3rd') is used, but will accept bool or null. [PR #4420](https://github.com/PHPOffice/PhpSpreadsheet/pull/4420)
51+
52+
### Fixed
53+
4054
- Ignore fractional part of Drawing Shadow Alpha. [Issue #4415](https://github.com/PHPOffice/PhpSpreadsheet/issues/4415) [PR #4417](https://github.com/PHPOffice/PhpSpreadsheet/pull/4417)
4155
- BIN2DEC, OCT2DEC, and HEX2DEC return numbers rather than strings. [Issue #4383](https://github.com/PHPOffice/PhpSpreadsheet/issues/4383) [PR #4389](https://github.com/PHPOffice/PhpSpreadsheet/pull/4389)
4256
- Fix TREND_BEST_FIT_NO_POLY. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)

bin/check-phpdoc-types renamed to bin/check-phpdoc-types.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* This will help us slowly migrate away from PHPDoc typing to PHP native typing.
1010
*/
11-
function checkPhpDocTypes(): void
11+
function checkPhpDocTypes(): int
1212
{
1313
$content = shell_exec('git diff --cached') ?? shell_exec('git diff') ?? shell_exec('git show HEAD');
1414
preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', "$content", $parameters);
@@ -19,11 +19,16 @@ function checkPhpDocTypes(): void
1919
...$returns[0],
2020
];
2121

22-
if ($errors) {
22+
if (!empty($errors)) {
2323
echo 'PHP native types must be used instead of PHPDoc types (without comments), for the following lines:' . PHP_EOL . PHP_EOL;
2424
echo implode(PHP_EOL, $errors) . PHP_EOL;
25-
exit(1);
25+
26+
return 1;
2627
}
28+
29+
return 0;
2730
}
2831

29-
checkPhpDocTypes();
32+
if (checkPhpDocTypes()) {
33+
exit(1);
34+
}

bin/generate-document renamed to bin/generate-document.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
55
use PhpOffice\PhpSpreadsheetInfra\DocumentGenerator;
66

7-
require_once 'vendor/autoload.php';
7+
require_once __DIR__ . '/..' . '/vendor/autoload.php';
88

99
$phpSpreadsheetFunctions = Calculation::getFunctions();
1010
ksort($phpSpreadsheetFunctions);

bin/generate-locales renamed to bin/generate-locales.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
55
use PhpOffice\PhpSpreadsheetInfra\LocaleGenerator;
66

7-
require_once 'vendor/autoload.php';
7+
require_once __DIR__ . '/..' . '/vendor/autoload.php';
88

99
$phpSpreadsheetFunctions = Calculation::getFunctions();
1010

bin/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [ "$files" != "" ]; then
2424
fi
2525

2626
# Check PHPDoc types
27-
./bin/check-phpdoc-types
27+
./bin/check-phpdoc-types.php
2828
if [ $? -ne 0 ]; then
2929
pass=false
3030
fi

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
],
4747
"scripts": {
4848
"check": [
49-
"php ./bin/check-phpdoc-types",
49+
"php bin/check-phpdoc-types.php",
5050
"phpcs samples/ src/ tests/ --report=checkstyle",
5151
"phpcs samples/ src/ tests/ --standard=PHPCompatibility --runtime-set testVersion 8.0- --exclude=PHPCompatibility.Variables.ForbiddenThisUseContexts -n",
5252
"php-cs-fixer fix --ansi --dry-run --diff",

infra/DocumentGenerator.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
class DocumentGenerator
1111
{
1212
/**
13-
* @param array[] $phpSpreadsheetFunctions
13+
* @param array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}> $phpSpreadsheetFunctions
1414
*/
15-
public static function generateFunctionListByCategory(array $phpSpreadsheetFunctions): string
15+
public static function generateFunctionListByCategory($phpSpreadsheetFunctions): string
1616
{
1717
$result = "# Function list by category\n";
1818
foreach (self::getCategories() as $categoryConstant => $category) {
@@ -33,11 +33,19 @@ public static function generateFunctionListByCategory(array $phpSpreadsheetFunct
3333
return $result;
3434
}
3535

36+
/** @return array<string, string> */
3637
private static function getCategories(): array
3738
{
38-
return (new ReflectionClass(Category::class))->getConstants();
39+
/** @var array<string, string> */
40+
$x = (new ReflectionClass(Category::class))->getConstants();
41+
42+
return $x;
3943
}
4044

45+
/**
46+
* @param int[] $lengths
47+
* @param null|array<int, int|string> $values
48+
*/
4149
private static function tableRow(array $lengths, ?array $values = null): string
4250
{
4351
$result = '';
@@ -46,13 +54,13 @@ private static function tableRow(array $lengths, ?array $values = null): string
4654
if ($i > 0) {
4755
$result .= '|' . $pad;
4856
}
49-
$result .= str_pad($value ?? '', $length, $pad);
57+
$result .= str_pad("$value", $length ?? 0, $pad);
5058
}
5159

5260
return rtrim($result, ' ');
5361
}
5462

55-
/** @param array<int,string>|scalar $functionCall */
63+
/** @param scalar|string|string[] $functionCall */
5664
private static function getPhpSpreadsheetFunctionText(mixed $functionCall): string
5765
{
5866
if (is_string($functionCall)) {
@@ -71,15 +79,14 @@ private static function getPhpSpreadsheetFunctionText(mixed $functionCall): stri
7179
}
7280

7381
/**
74-
* @param array[] $phpSpreadsheetFunctions
82+
* @param array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}> $phpSpreadsheetFunctions
7583
*/
7684
public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string
7785
{
7886
$categoryConstants = array_flip(self::getCategories());
7987
$result = "# Function list by name\n";
8088
$lastAlphabet = null;
8189
foreach ($phpSpreadsheetFunctions as $excelFunction => $functionInfo) {
82-
/** @var string $excelFunction */
8390
$lengths = [25, 31, 37];
8491
if ($lastAlphabet !== $excelFunction[0]) {
8592
$lastAlphabet = $excelFunction[0];

0 commit comments

Comments
 (0)