Skip to content

Commit 6fd17cc

Browse files
authored
Upgrade PHPStan to 2.0 (#1256)
1 parent d689aed commit 6fd17cc

File tree

37 files changed

+97
-110
lines changed

37 files changed

+97
-110
lines changed

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ parameters:
22
level: 8
33
treatPhpDocTypesAsCertain: false
44
ignoreErrors:
5+
- identifier: argument.type
56
- identifier: missingType.iterableValue
67
- identifier: missingType.generics
78
paths:

src/adapter/etl-adapter-csv/src/Flow/ETL/Adapter/CSV/CSVExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function extract(FlowContext $context) : \Generator
5959
continue;
6060
}
6161

62-
/** @var array<mixed> $rowData */
62+
/** @var non-empty-list<null|string> $rowData */
6363
$rowData = \str_getcsv($csvLine, $separator, $enclosure, $escape);
6464

6565
if (!\count($headers)) {

src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/DbalLimitOffsetExtractor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function extract(FlowContext $context) : \Generator
5555
} else {
5656
$countQuery = (clone $this->queryBuilder)->select('COUNT(*)');
5757

58+
// @phpstan-ignore-next-line
5859
if (\method_exists($countQuery, 'resetOrderBy')) {
5960
$countQuery->resetOrderBy();
6061
} else {

src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/Parameter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ public function queryParamName() : string
3737
return $this->queryParamName;
3838
}
3939

40-
public function toQueryParam(Rows $rows) : mixed
40+
/**
41+
* @return array<array-key, null|bool|float|int|string>
42+
*/
43+
public function toQueryParam(Rows $rows) : array
4144
{
4245
return $rows->reduceToArray($this->ref);
4346
}
4447

45-
public function type() : int|ArrayParameterType|null
48+
public function type() : int|ArrayParameterType
4649
{
4750
return $this->type;
4851
}

src/adapter/etl-adapter-elasticsearch/src/Flow/ETL/Adapter/Elasticsearch/ElasticsearchPHP/ElasticsearchExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
final class ElasticsearchExtractor implements Extractor
1010
{
1111
/**
12-
* @phpstan-ignore-next-line
13-
*
1412
* @psalm-suppress UndefinedClass
13+
*
14+
* @phpstan-ignore-next-line
1515
*/
1616
private \Elasticsearch\Client|\Elastic\Elasticsearch\Client|null $client;
1717

src/adapter/etl-adapter-logger/src/Flow/ETL/Adapter/Logger/PsrLoggerLoader.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ public function __construct(private LoggerInterface $logger, private string $mes
1515

1616
public function load(Rows $rows, FlowContext $context) : void
1717
{
18-
/**
19-
* @psalm-var callable(Row) : void $loader
20-
*/
2118
$loader = function (Row $row) : void {
2219
$this->logger->log($this->logLevel, $this->message, $row->toArray());
2320
};

src/core/etl/src/Flow/ETL/Config/Cache/CacheConfigBuilder.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ final class CacheConfigBuilder
2222

2323
public function build(FilesystemTable $fstab, Serializer $serializer) : CacheConfig
2424
{
25-
$cachePath = \is_string(\getenv(CacheConfig::CACHE_DIR_ENV)) && \getenv(CacheConfig::CACHE_DIR_ENV) !== ''
26-
? \getenv(CacheConfig::CACHE_DIR_ENV)
27-
: \sys_get_temp_dir() . '/flow_php/cache';
28-
29-
if (!\is_string($cachePath)) {
30-
throw new RuntimeException('Cache directory must be a string, got ' . \gettype($cachePath));
31-
}
25+
$cachePath = \getenv(CacheConfig::CACHE_DIR_ENV) ?: '';
26+
$cachePath = $cachePath !== '' ? $cachePath : \sys_get_temp_dir() . '/flow_php/cache';
3227

3328
if (!\file_exists($cachePath)) {
3429
if (!mkdir($cachePath, 0777, true) && !is_dir($cachePath)) {

src/core/etl/src/Flow/ETL/DataFrame.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,14 @@ public static function fromArray(array $definition) : self
110110
}
111111

112112
/**
113-
* @throws \JsonException
114113
* @throws InvalidArgumentException
115114
*/
116115
public static function fromJson(string $json) : self
117116
{
118117
try {
119118
return self::fromArray(\json_decode($json, true, 512, JSON_THROW_ON_ERROR));
120119
} catch (\JsonException $exception) {
121-
throw new InvalidFileFormatException('json', 'unknown');
120+
throw new InvalidFileFormatException('json', 'unknown', $exception);
122121
}
123122
}
124123

src/core/etl/src/Flow/ETL/Extractor/LimitableExtractor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
namespace Flow\ETL\Extractor;
66

7+
use Flow\ETL\Extractor;
8+
79
/**
810
* Limitable extractor is one that can be limited to extract only given number of rows.
911
* Whenever limit is set in a pipeline before any transformations, LogicalPlan processor will try
1012
* to grab that limit and inject it directly to the extractor to avoid unnecessary processing.
1113
*/
12-
interface LimitableExtractor
14+
interface LimitableExtractor extends Extractor
1315
{
1416
public function changeLimit(int $limit) : void;
1517

src/core/etl/src/Flow/ETL/Function/Split.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct(
1515
) {
1616
}
1717

18-
public function eval(Row $row) : array|string|null
18+
public function eval(Row $row) : ?array
1919
{
2020
$value = (new Parameter($this->value))->asString($row);
2121
$separator = (new Parameter($this->separator))->asString($row);

0 commit comments

Comments
 (0)