From c105457d2080dd3d5388553c5fd0e41ecc237275 Mon Sep 17 00:00:00 2001 From: sebprt Date: Wed, 22 Nov 2023 14:35:34 +0100 Subject: [PATCH] Added PHPStan rule to ignore while(true) statement --- src/CSV/FingersCrossed/Loader.php | 4 +++- src/CSV/Safe/Loader.php | 4 +++- src/Sheet/FingersCrossed/Loader.php | 4 +++- src/Sheet/Safe/Loader.php | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/CSV/FingersCrossed/Loader.php b/src/CSV/FingersCrossed/Loader.php index 78e28fc..7614357 100644 --- a/src/CSV/FingersCrossed/Loader.php +++ b/src/CSV/FingersCrossed/Loader.php @@ -27,7 +27,7 @@ public function __construct( public function load(): \Generator { - $line = yield; + $line = yield new EmptyResultBucket(); try { $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null) @@ -41,6 +41,7 @@ public function load(): \Generator ); } + /* @phpstan-ignore-next-line */ while (true) { try { $this->writer->addRow( @@ -53,6 +54,7 @@ public function load(): \Generator $exception, $line ); + continue; } $line = yield new AcceptanceResultBucket($line); diff --git a/src/CSV/Safe/Loader.php b/src/CSV/Safe/Loader.php index 29a2f16..a27ed69 100644 --- a/src/CSV/Safe/Loader.php +++ b/src/CSV/Safe/Loader.php @@ -42,7 +42,8 @@ public function load(): \Generator ); } - while ($line) { + /* @phpstan-ignore-next-line */ + while (true) { try { $this->writer->addRow($this->orderColumns($headers, $line)); } catch (IOException|WriterNotOpenedException $exception) { @@ -52,6 +53,7 @@ public function load(): \Generator $exception, $line ); + continue; } $line = yield new AcceptanceResultBucket($line); diff --git a/src/Sheet/FingersCrossed/Loader.php b/src/Sheet/FingersCrossed/Loader.php index 255b55c..2321faa 100644 --- a/src/Sheet/FingersCrossed/Loader.php +++ b/src/Sheet/FingersCrossed/Loader.php @@ -46,7 +46,8 @@ public function load(): \Generator ); } - while ($line) { + /* @phpstan-ignore-next-line */ + while (true) { try { $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), $line), null) @@ -58,6 +59,7 @@ public function load(): \Generator $exception, $line ); + continue; } $line = yield new AcceptanceResultBucket($line); diff --git a/src/Sheet/Safe/Loader.php b/src/Sheet/Safe/Loader.php index 16f67f4..bcea776 100644 --- a/src/Sheet/Safe/Loader.php +++ b/src/Sheet/Safe/Loader.php @@ -46,7 +46,8 @@ public function load(): \Generator ); } - while ($line) { + /* @phpstan-ignore-next-line */ + while (true) { try { $this->writer->addRow($this->orderColumns($headers, $line)); } catch (IOException|WriterNotOpenedException $exception) { @@ -56,6 +57,7 @@ public function load(): \Generator $exception, $line ); + continue; } $line = yield new AcceptanceResultBucket($line);