PHPackages                             cspray/annotated-target - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cspray/annotated-target

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cspray/annotated-target
=======================

A PHP 8 library for statically parsing Attributes using PHP-Parser.

v2.0.0.alpha.2(1y ago)211.5k↓45.9%[1 issues](https://github.com/cspray/annotated-target/issues)1MITPHPPHP ^8.1

Since Jun 7Pushed 1y ago2 watchersCompare

[ Source](https://github.com/cspray/annotated-target)[ Packagist](https://packagist.org/packages/cspray/annotated-target)[ RSS](/packages/cspray-annotated-target/feed)WikiDiscussions release-1.x Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (1)

Annotated Target
================

[](#annotated-target)

A static analysis tool for PHP 8 to gather all the places Attributes are used in a given codebase. In short, give this tool a set of directories, and we'll provide a Generator that yields information wherever an Attribute is found. You can filter by Attribute types to get info for just the things you need. Check out the Quick Start below for more info.

Install
-------

[](#install)

Use Composer to install this package.

```
composer require cspray/annotated-target
```

Quick Start
-----------

[](#quick-start)

The core concept in Annotated Target is an interface called `AnnotatedTarget` that tracks information about each place an Attribute is used in your codebase. It provides three pieces of data:

1. The `Reflector` that the Attribute was targeting. For example, if the Attribute was found targeting a class then a `ReflectionClass` would be available.
2. The `ReflectionAttribute` for the Attribute.
3. The instance for the given Attribute.

Let's take a look at some annotated code and how you'd get access to the parsed Attributes. We'll assume that this code exists in `__DIR__ . 'src/Foo.php'`.

```
