diff --git a/Makefile b/Makefile index 0d4adf8b5f..e104ac7c19 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ lint: --exclude tests/PHPStan/Rules/Names/data \ --exclude tests/PHPStan/Rules/Operators/data/invalid-inc-dec.php \ --exclude tests/PHPStan/Rules/Arrays/data/offset-access-without-dim-for-reading.php \ + --exclude tests/PHPStan/Rules/Classes/data/bug-11891.php \ --exclude tests/PHPStan/Rules/Classes/data/bug-13768.php \ --exclude tests/PHPStan/Rules/Classes/data/duplicate-declarations.php \ --exclude tests/PHPStan/Rules/Classes/data/duplicate-enum-cases.php \ diff --git a/tests/PHPStan/Rules/Classes/EnumSanityRuleTest.php b/tests/PHPStan/Rules/Classes/EnumSanityRuleTest.php index 4ab2c6b842..a98a79e449 100644 --- a/tests/PHPStan/Rules/Classes/EnumSanityRuleTest.php +++ b/tests/PHPStan/Rules/Classes/EnumSanityRuleTest.php @@ -179,4 +179,15 @@ public function testBug13768(): void ]); } + #[RequiresPhp('>= 8.1')] + public function testBug11891(): void + { + $this->analyse([__DIR__ . '/data/bug-11891.php'], [ + [ + 'Enum Bug11891\test has duplicate value 42 for cases A, B.', + 5, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Classes/data/bug-11891.php b/tests/PHPStan/Rules/Classes/data/bug-11891.php new file mode 100644 index 0000000000..b4cea7afd3 --- /dev/null +++ b/tests/PHPStan/Rules/Classes/data/bug-11891.php @@ -0,0 +1,8 @@ += 8.1 + +namespace Bug11891; + +enum test:int { + case A = 42; + case B = self::A->value; +};