PHPackages                             fatcode/annotations - 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. fatcode/annotations

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

fatcode/annotations
===================

Annotations library

1.2.0(7y ago)053MITPHPPHP &gt;=7.2.0

Since Mar 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/fatcode/annotations)[ Packagist](https://packagist.org/packages/fatcode/annotations)[ RSS](/packages/fatcode-annotations/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

FatCode Annotations [![Build Status](https://camo.githubusercontent.com/d6ab0b584f0637ac8dec4c432493d76fa5a67dd78919c371813dd41395abf23a/68747470733a2f2f7472617669732d63692e6f72672f666174636f64652f616e6e6f746174696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fatcode/annotations) [![Maintainability](https://camo.githubusercontent.com/87e02edaa1271abfdec01ce21e10ed4fe358cf974378beaaea06bc2ccfb20e6d/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36613238663930393631313937643433373032652f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/fatcode/annotations/maintainability) [![Test Coverage](https://camo.githubusercontent.com/141b4dbef86fce6ab3c580a0fbe504e9c4595d0488e666243f73822c15cb55d1/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36613238663930393631313937643433373032652f746573745f636f766572616765)](https://codeclimate.com/github/fatcode/annotations/test_coverage)
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#fatcode-annotations---)

Introduction
------------

[](#introduction)

Annotations is an attempt to provide meta data programing for php by extending docblock comments. Syntax is compatible with latest [annotations rfc](https://wiki.php.net/rfc/annotations_v2).

### Installation

[](#installation)

`composer install fatcode/annotations`

### Differences from RFC

[](#differences-from-rfc)

The following annotations are not supported for various reasons:

- `@Compiled` - as there is no compiling
- `@SupressWarning` - There is no simple way to implement it in user-land
- `@Repeatable` - all annotations are repeatable by default
- `@Inherited` - same as `@SupressWarning`, there is no simple way to track php's inheritance tree in user-land

### Built-in annotations

[](#built-in-annotations)

- `@Annotation()` - makes class available as annotation
- `@Required()` - ensures that attribute is passed when annotation is used
- `@NoValidate()` - turns off attribute validation
- `@Enum(mixed ...$value)` - defines valid values for annotated property
- `@Target(string ...$target)` - declares valid targets for annotation

Defining an annotation
----------------------

[](#defining-an-annotation)

```
