# PHP Annotations Plugin Navigation

**Navigation** features connect DocBlock annotations and attribute values to annotation classes, annotation properties, imports, class constants, Doctrine repositories, Doctrine fields, and framework-specific targets.

---

## Navigate from annotations to classes and properties

**Feature ID:** `AnnotationGoto`  
**Feature Page:** [Navigate from annotations to classes and properties](https://espend.de/phpstorm/plugin/php-annotations#annotation-goto)  

Ctrl-click or Go to Declaration from a DocBlock annotation name opens the annotation class. Property names inside annotation arguments resolve to the backing PHP field or contributed virtual property target.

Class constants in DocBlocks resolve to their class or constant field, including namespace aliases and `::class` references.

### Code Examples

```php
# Navigation targets:
use App\Annotation\Audit;
use App\Routing\RouteName;

/**
 * @Audit(message="created", route=RouteName::PRODUCT_SHOW)
 */
final class Product {}
```

```text
# Supported jumps:
@Audit -> App\Annotation\Audit
message -> Audit::$message
RouteName -> App\Routing\RouteName
PRODUCT_SHOW -> RouteName::PRODUCT_SHOW
```

---

## References from annotation and attribute values

**Feature ID:** `AnnotationValueReferences`  
**Feature Page:** [References from annotation and attribute values](https://espend.de/phpstorm/plugin/php-annotations#annotation-value-references)  

Annotation value reference providers connect string values to framework-specific targets. The central bridge supports DocBlock default values, named DocBlock properties, attribute default values, and named attribute arguments.

Doctrine uses this for repository classes, entity fields, DBAL types, embeddables, and custom ID generator classes.

### Code Examples

```php
# DocBlock reference:
/**
 * @ORM\Entity(repositoryClass="ProductRepository")
 */
final class Product {}
```

```php
# Attribute reference:
#[ORM\ManyToMany(targetEntity: Category::class, mappedBy: 'products')]
private Collection $categories;
```

---

## Optimize Imports keeps annotation imports

**Feature ID:** `OptimizeImportsBridge`  
**Feature Page:** [Optimize Imports keeps annotation imports](https://espend.de/phpstorm/plugin/php-annotations#optimize-imports-bridge)  

The plugin attaches real PSI references from annotation DocTags to imported classes and namespace aliases.

This prevents PhpStorm's `Code > Optimize Imports` action from removing imports that are only used inside DocBlocks.

### Code Examples

```php
# DocBlock-only import usage:
use Doctrine\ORM\Mapping as ORM;

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

```php
# Class constants count as usage too:
use App\Routing\RouteName;

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

---

