Error Identifier: doctrine.descriptorNotFound
Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
<?php declare(strict_types = 1);
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class User
{
#[ORM\Column(type: 'custom_type')]
private string $name;
}
Why is it reported? #
This error is reported by the phpstan-doctrine extension.
The Doctrine column mapping uses a type (custom_type) that does not have a registered type descriptor. PHPStan cannot validate the type mapping for this column because the type descriptor is missing from the descriptor registry.
How to fix it #
Register the custom Doctrine type in your configuration, or use a built-in Doctrine type:
<?php declare(strict_types = 1);
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class User
{
- #[ORM\Column(type: 'custom_type')]
+ #[ORM\Column(type: 'string')]
private string $name;
}
If using a custom type, make sure it is properly registered with Doctrine’s type system and configure the phpstan-doctrine extension to recognise it.
How to ignore this error #
You can use the identifier doctrine.descriptorNotFound to ignore this error using a comment:
// @phpstan-ignore doctrine.descriptorNotFound
codeThatProducesTheError();
You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:
parameters:
ignoreErrors:
-
identifier: doctrine.descriptorNotFound
Rules that report this error #
- PHPStan\Rules\Doctrine\ORM\EntityColumnRule [1] phpstan/phpstan-doctrine