phpstan-doctrine icon indicating copy to clipboard operation
phpstan-doctrine copied to clipboard

Register DBAL types automatically so that `EntityColumnRule` works without defining a `objectManagerLoader`

Open ruudk opened this issue 3 years ago • 1 comments

The goal is to use the extension without having to provide a objectManagerLoader.

The base functionality was added in https://github.com/phpstan/phpstan-doctrine/pull/253.

Because EntityColumnRule uses DescriptorRegistry and that uses DBAL's Type::getTypesMap we need to make sure that all types are defined there as well.

To make that easy, I quickly hacked the ReflectionDescriptor to automatically register the type.

As a bonus, I also did the UuidTypeDescriptor.

Now I can run it without having to instantiate the Symfony container.

@ondrejmirtes This is a POC, what's the best way to address this?

ruudk avatar Jan 24 '22 15:01 ruudk

Can you please show what kind of code pattern PHPStan fails - what is this trying to solve? I have some idea but perhaps when we explain things clearly, a solution emerges more easily :)

ondrejmirtes avatar Jan 24 '22 15:01 ondrejmirtes