Skip to content

Commit 3c7afe6

Browse files
authored
Merge pull request #4447 from oleibman/stan1002
Phpstan 10 and IterableValue Prep Part 2
2 parents e831636 + 1bd8bd9 commit 3c7afe6

File tree

73 files changed

+631
-340
lines changed

Some content is hidden

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

73 files changed

+631
-340
lines changed

infra/DocumentGenerator.php

Lines changed: 4 additions & 5 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) {
@@ -60,7 +60,7 @@ private static function tableRow(array $lengths, ?array $values = null): string
6060
return rtrim($result, ' ');
6161
}
6262

63-
/** @param array<int,string>|scalar $functionCall */
63+
/** @param scalar|string|string[] $functionCall */
6464
private static function getPhpSpreadsheetFunctionText(mixed $functionCall): string
6565
{
6666
if (is_string($functionCall)) {
@@ -79,15 +79,14 @@ private static function getPhpSpreadsheetFunctionText(mixed $functionCall): stri
7979
}
8080

8181
/**
82-
* @param array<string, array<string, int|string>> $phpSpreadsheetFunctions
82+
* @param array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}> $phpSpreadsheetFunctions
8383
*/
8484
public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string
8585
{
8686
$categoryConstants = array_flip(self::getCategories());
8787
$result = "# Function list by name\n";
8888
$lastAlphabet = null;
8989
foreach ($phpSpreadsheetFunctions as $excelFunction => $functionInfo) {
90-
/** @var string $excelFunction */
9190
$lengths = [25, 31, 37];
9291
if ($lastAlphabet !== $excelFunction[0]) {
9392
$lastAlphabet = $excelFunction[0];

infra/LocaleGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LocaleGenerator
3030

3131
protected string $translationBaseFolder;
3232

33-
/** @var string[] */
33+
/** @var array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}> */
3434
protected array $phpSpreadsheetFunctions;
3535

3636
protected Spreadsheet $translationSpreadsheet;
@@ -42,19 +42,19 @@ class LocaleGenerator
4242
/** @var string[] */
4343
protected array $localeLanguageMap = [];
4444

45-
/** @var array<string, int> */
45+
/** @var int[] */
4646
protected array $errorCodeMap = [];
4747

4848
private Worksheet $functionNameTranslations;
4949

5050
/** @var string[] */
5151
protected array $functionNameLanguageMap = [];
5252

53-
/** @var array<string, int|string> */
53+
/** @var array<int|string> */
5454
protected array $functionNameMap = [];
5555

5656
/**
57-
* @param string[] $phpSpreadsheetFunctions
57+
* @param array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}> $phpSpreadsheetFunctions
5858
*/
5959
public function __construct(
6060
string $translationBaseFolder,

phpstan.neon.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ parameters:
2121
- src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php
2222
- src/PhpSpreadsheet/Writer/ZipStream2.php
2323
- src/PhpSpreadsheet/Writer/ZipStream3.php
24+
#- tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFunctions2Test.php
2425
parallel:
2526
processTimeout: 300.0
2627
ignoreErrors:
2728
# Accept a bit anything for assert methods
2829
- '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~'
30+
#- '~Method .*rovider.* return type has no value type specified in iterable type array\.$~'
2931
- identifier: missingType.iterableValue

samples/Basic/05_Feature_demo.php

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

33
require __DIR__ . '/../Header.php';
4-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
4+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
55
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
66

77
// Save
8+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
89
$helper->write($spreadsheet, __FILE__);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
require __DIR__ . '/../Header.php';
4-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
4+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
55
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet2.php';
66

77
// Save
8+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
89
$helper->write($spreadsheet, __FILE__);

samples/Basic/06_Largescale.php

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

33
require __DIR__ . '/../Header.php';
4-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
4+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
55
$spreadsheet = require __DIR__ . '/../templates/largeSpreadsheet.php';
66

77
// Save
8+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
89
$helper->write($spreadsheet, __FILE__);

samples/Basic/07_Reader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
55

66
require __DIR__ . '/../Header.php';
7-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
87

98
// Create temporary file that will be read
9+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
1010
$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
11+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
1112
$filename = $helper->getTemporaryFilename();
1213
$writer = new Xlsx($sampleSpreadsheet);
1314
$writer->save($filename);

samples/Basic1/14_Xls.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
use PhpOffice\PhpSpreadsheet\IOFactory;
44

55
require __DIR__ . '/../Header.php';
6-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
6+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
77
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
88

9+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
910
$filename = $helper->getFilename(__FILE__, 'xls');
1011
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
1112

samples/Basic1/16_Csv.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
use PhpOffice\PhpSpreadsheet\Writer\Csv as CsvWriter;
55

66
require __DIR__ . '/../Header.php';
7-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
7+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
88
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
99

10+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
1011
$helper->log('Write to CSV format');
1112
$writer = new CsvWriter($spreadsheet);
1213
$writer->setDelimiter(',')

samples/Basic1/17_Html.php

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

33
require __DIR__ . '/../Header.php';
4-
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
4+
/** @var PhpOffice\PhpSpreadsheet\Spreadsheet */
55
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
66
$spreadsheet->getProperties()->setTitle('Non-embedded images');
77

8+
/** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */
89
$helper->write($spreadsheet, __FILE__, ['Html']);

0 commit comments

Comments
 (0)