# PHP Annotations Plugin Completion

**Completion** features provide context-aware suggestions for PHP DocBlock annotations, PHP attributes, annotation properties, enum and boolean values, class constants, Symfony Route methods, and Doctrine mapping values.

---

## Annotation class completion with target filtering

**Feature ID:** `AnnotationClassCompletion`  
**Feature Page:** [Annotation class completion with target filtering](https://espend.de/phpstorm/plugin/php-annotations#annotation-class-completion)  

Completes annotation classes in PHP DocBlocks and filters suggestions by the current target, so class annotations, method annotations, property annotations, and nested annotations stay relevant.

Classes are discovered from the project index when they declare `@Annotation`. Their `@Target` declaration controls where they are suggested; annotations without an explicit target remain available as generic annotations.

### Code Examples

```php
# Target-aware DocBlock completion:
/**
 * @Annotation
 * @Target("PROPERTY")
 */
final class Slug {}

final class Product
{
    /**
     * @<caret>
     */
    private string $slug;
}
```

```php
# Alias-aware insert result:
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 */
final class Product {}
```

---

## Annotation property name completion

**Feature ID:** `AnnotationPropertyCompletion`  
**Feature Page:** [Annotation property name completion](https://espend.de/phpstorm/plugin/php-annotations#annotation-property-completion)  

Completes annotation property names from public annotation fields and Doctrine-style `@Attributes` metadata.

Virtual properties can be contributed by extension points, so frameworks can expose synthetic annotation arguments even when they are not real PHP fields.

### Code Examples

```php
# Annotation class metadata:
/**
 * @Annotation
 * @Attributes({
 *     @Attribute("message", type="string"),
 *     @Attribute("groups", type="array")
 * })
 */
final class NotBlank {}
```

```php
# Completion usage:
/**
 * @NotBlank(<caret>)
 */
private string $name;
```

---

## Typed property value completion

**Feature ID:** `AnnotationPropertyValueCompletion`  
**Feature Page:** [Typed property value completion](https://espend.de/phpstorm/plugin/php-annotations#annotation-property-value-completion)  

Completes values inside annotation and attribute arguments from the annotation class metadata.

Boolean fields offer `true`/`false`, `@Enum` declarations offer their allowed values, and array properties are handled separately so single-value suggestions do not leak into array-only contexts.

### Code Examples

```php
# Annotation metadata:
/**
 * @Annotation
 */
final class GeneratedValue
{
    /**
     * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "UUID", "CUSTOM"})
     */
    public string $strategy = 'AUTO';

    public bool $enabled = true;
}
```

```php
# DocBlock and attribute completion:
/**
 * @ORM\GeneratedValue(strategy="<caret>")
 */
private int $id;

#[ORM\GeneratedValue(strategy: '<caret>')]
private int $id;
```

---

## Nested annotation completion

**Feature ID:** `NestedAnnotationCompletion`  
**Feature Page:** [Nested annotation completion](https://espend.de/phpstorm/plugin/php-annotations#nested-annotation-completion)  

Supports completion inside nested annotation expressions, including nested arrays and whitespace variants in DocBlocks.

This is important for annotations that accept other annotations as structured configuration values.

### Code Examples

```php
# Nested annotation values:
/**
 * @Security({
 *     @AccessControl(role="<caret>")
 * })
 */
public function edit(): Response
{
}
```

```php
# Nested completion scope:
/**
 * @Foo(foo={@Bar(<caret>)})
 */
final class Example {}
```

---

## PHP attribute alias completion

**Feature ID:** `AttributeAliasCompletion`  
**Feature Page:** [PHP attribute alias completion](https://espend.de/phpstorm/plugin/php-annotations#attribute-alias-completion)  

Completes PHP attributes through the same alias configuration used for DocBlock annotations.

The completion uses existing `use ... as ...` imports and configured aliases, then verifies that the underlying class is a valid PHP attribute for the current declaration target.

### Code Examples

```php
# Before completion:
final class Product
{
    #[<caret>]
    private string $name;
}
```

```php
# After selecting an alias item:
use Symfony\Component\Validator\Constraints as Assert;

final class Product
{
    #[Assert\NotBlank()]
    private string $name;
}
```

---

## Class constant completion in DocBlocks

**Feature ID:** `ClassConstantCompletion`  
**Feature Page:** [Class constant completion in DocBlocks](https://espend.de/phpstorm/plugin/php-annotations#class-constant-completion)  

Completes constants after `::` inside annotation arguments and array arguments.

The same class-constant support also participates in navigation and import usage detection, so constants referenced from DocBlocks are treated as real class usages.

### Code Examples

```php
# Constant completion:
use App\Routing\RouteName;

/**
 * @Route(name=RouteName::<caret>)
 */
public function show(): Response
{
}
```

```php
# Constant inside an array value:
/**
 * @SomeAnnotation(values={RouteName::ADMIN, RouteName::<caret>})
 */
final class Example {}
```

---

## Symfony Route method completion

**Feature ID:** `SymfonyRouteMethodsCompletion`  
**Feature Page:** [Symfony Route method completion](https://espend.de/phpstorm/plugin/php-annotations#symfony-route-methods-completion)  

Completes HTTP methods for Symfony Route annotations and Route attributes when the caret is inside the `methods` array.

Supported targets are `Symfony\Component\Routing\Annotation\Route` and `Symfony\Component\Routing\Attribute\Route`.

### Code Examples

```php
# Route annotation:
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/product", methods={"<caret>"})
 */
public function list(): Response
{
}
```

```php
# Route attribute:
use Symfony\Component\Routing\Attribute\Route;

#[Route('/product', methods: ['<caret>'])]
public function list(): Response
{
}
```

---

