Skip to content

Commit

Permalink
Added PHPStan rule to ignore while(true) statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Nov 22, 2023
1 parent 192f6b6 commit c105457
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/CSV/FingersCrossed/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -41,6 +41,7 @@ public function load(): \Generator
);
}

/* @phpstan-ignore-next-line */
while (true) {
try {
$this->writer->addRow(
Expand All @@ -53,6 +54,7 @@ public function load(): \Generator
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down
4 changes: 3 additions & 1 deletion src/CSV/Safe/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -52,6 +53,7 @@ public function load(): \Generator
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down
4 changes: 3 additions & 1 deletion src/Sheet/FingersCrossed/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -58,6 +59,7 @@ public function load(): \Generator
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down
4 changes: 3 additions & 1 deletion src/Sheet/Safe/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -56,6 +57,7 @@ public function load(): \Generator
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down

0 comments on commit c105457

Please sign in to comment.