PHP Architecture Test - Final enum reproducer
This package is a reproducer of a bug in phpat/phpat
.
When testing classes in a specific namespace are not final, PHPat throws an error if an enum is in that namespace.
Installation
After cloning this repository, install the Composer dependencies.
composer install
Usage
./vendor/bin/phpstan
Workaround
It seems that enums are considered final by PHP (see ReflectionEnum
API), so it's not a bug of PHPat.
$reflectionEnum = new \ReflectionEnum(FooEnum::class);
var_dump($reflectionEnum->isFinal()); //true
The solution is to have the following test:
final class EntityNotFinalTest
{
public function testEntityClassesAreNotFinal(): Rule
{
return PHPat::rule()
->classes(Selector::namespace('App\Entity'))
->excluding(Selector::enum())
->shouldNotBeFinal()
;
}
}