Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
takaram authored and ondrejmirtes committed Jun 7, 2023
1 parent d09401d commit ffc0495
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,13 @@ public function testBug7314(): void
$this->analyse([__DIR__ . '/data/bug-7314.php'], []);
}

public function testBug8412(): void
{
if (PHP_VERSION_ID < 80100) {
$this->markTestSkipped('Test requires PHP 8.1.');
}

$this->analyse([__DIR__ . '/data/bug-8412.php'], []);
}

}
25 changes: 25 additions & 0 deletions tests/PHPStan/Rules/Properties/data/bug-8412.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1); // lint >= 8.1

namespace Bug8412;

use InvalidArgumentException;

enum Zustand: string
{
case Failed = 'failed';
case Pending = 'pending';
}

final class HelloWorld
{
public readonly ?int $value;

public function __construct(Zustand $zustand)
{
$this->value = match ($zustand) {
Zustand::Failed => 1,
Zustand::Pending => 2,
default => throw new InvalidArgumentException('Unknown Zustand: ' . $zustand->value),
};
}
}

0 comments on commit ffc0495

Please sign in to comment.