# PHP Annotations Plugin Doctrine

**Doctrine** features support Doctrine ORM annotations, PHP attributes, DBAL type metadata, mapping references, repository classes, and generated entity metadata.

---

## Doctrine mapping references

**Feature ID:** `DoctrineMappingReferences`  
**Feature Page:** [Doctrine mapping references](https://espend.de/phpstorm/plugin/php-annotations#doctrine-mapping-references)  

Adds completion and navigation for common Doctrine ORM mapping values.

Supported mappings include `repositoryClass`, `targetEntity`, `mappedBy`, `inversedBy`, embedded class references, and custom ID generator classes.

### Code Examples

```php
# DocBlock relation field completion:
/**
 * @ORM\ManyToMany(targetEntity="Category", inversedBy="<caret>")
 */
private Collection $categories;
```

```php
# Attribute relation field completion:
#[ORM\ManyToMany(targetEntity: Category::class, mappedBy: '<caret>')]
private Collection $categories;
```

---

## Doctrine column type completion and navigation

**Feature ID:** `DoctrineColumnTypes`  
**Feature Page:** [Doctrine column type completion and navigation](https://espend.de/phpstorm/plugin/php-annotations#doctrine-column-types)  

Completes Doctrine DBAL type names in `@ORM\Column(type=...)` and resolves them back to their type classes.

The provider reads custom subclasses of `Doctrine\DBAL\Types\Type`, Doctrine 3 `Doctrine\DBAL\Types\Types` constants, and static fallback types.

### Code Examples

```php
# Column type completion:
/**
 * @ORM\Column(type="<caret>")
 */
private array $payload = [];
```

```php
# Doctrine 3 type source:
final class Types
{
    public const JSON = 'json';
}
```

---

## Doctrine column name suggestions

**Feature ID:** `DoctrineColumnNameCompletion`  
**Feature Page:** [Doctrine column name suggestions](https://espend.de/phpstorm/plugin/php-annotations#doctrine-column-name-completion)  

Suggests snake_case column names from PHP property names for Doctrine `Column`, `JoinColumn`, and `InverseJoinColumn` mappings.

The attribute path also supports constructor promoted properties, so modern readonly entity style remains covered.

### Code Examples

```php
# Property mapping:
/**
 * @ORM\Column(name="<caret>")
 */
private string $createdAt;
```

```php
# Promoted property mapping:
public function __construct(
    #[ORM\Column(name: '<caret>')]
    private readonly int $attributeId,
) {
}
```

---

## Doctrine static value completion

**Feature ID:** `DoctrineStaticValues`  
**Feature Page:** [Doctrine static value completion](https://espend.de/phpstorm/plugin/php-annotations#doctrine-static-values)  

Completes known Doctrine static string values where the valid set is small and mapping-specific.

For example, `JoinColumn(onDelete=...)` offers the supported delete actions without polluting array-value contexts.

### Code Examples

```php
# DocBlock mapping:
/**
 * @ORM\JoinColumn(onDelete="<caret>")
 */
private ?Category $category = null;
```

```php
# Attribute mapping:
#[ORM\JoinColumn(onDelete: '<caret>')]
private ?Category $category = null;
```

---

