rfc:reflection_doccomment_annotations
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Next revision | |||
— | rfc:reflection_doccomment_annotations [2013/01/06 21:53] – created yahavgb | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Request for Comments: Reflection Annotations using the Doc-Comment ====== | ||
+ | * Version: 1.0 | ||
+ | * Date: 2013-01-06 | ||
+ | * Author: Yahav Gindi Bar < | ||
+ | * Status: Under Discussion | ||
+ | * First Published at: http:// | ||
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | This RFC proposes to improve the Reflection extension with methods that can interact with the doc-comment in order to retrieve decorated annotations. | ||
+ | |||
+ | ==== Why do we need it? ==== | ||
+ | |||
+ | Today' | ||
+ | |||
+ | ===== About the implementation ===== | ||
+ | |||
+ | This RFC propose is to include the ability to read doc-comment annotations directly from Reflection. | ||
+ | You should note that this implementation does not contains any complex features such as " | ||
+ | This implementation only gives access to the decorated annotations values. | ||
+ | |||
+ | ===== Simple examples ===== | ||
+ | <code php> | ||
+ | /* | ||
+ | * This class representing a user. | ||
+ | * @Table(" | ||
+ | */ | ||
+ | class User | ||
+ | { | ||
+ | /** | ||
+ | * The user id | ||
+ | * @var Integer | ||
+ | * @Key | ||
+ | | ||
+ | private $id; | ||
+ | | ||
+ | /** | ||
+ | * The user name | ||
+ | * @var String | ||
+ | * @MaxLength 255 | ||
+ | * @Type varchar | ||
+ | | ||
+ | private $name; | ||
+ | } | ||
+ | |||
+ | $han = new ReflectionClass(" | ||
+ | |||
+ | print_r($han-> | ||
+ | |||
+ | print_r($han-> | ||
+ | var_dump($han-> | ||
+ | var_dump($han-> | ||
+ | </ | ||
+ | |||
+ | ===== Applications that uses metadata today ===== | ||
+ | |||
+ | 1. Symfony | ||
+ | <code php> | ||
+ | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
+ | |||
+ | class PostController extends Controller | ||
+ | { | ||
+ | /** | ||
+ | * @Route("/" | ||
+ | */ | ||
+ | public function indexAction() | ||
+ | { | ||
+ | // ... | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 2. Doctorine | ||
+ | <code php> | ||
+ | class User | ||
+ | { | ||
+ | //... | ||
+ | /** | ||
+ | * @ManyToMany(targetEntity=" | ||
+ | */ | ||
+ | private $groups; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== User-land implementations ===== | ||
+ | |||
+ | Well-known implementations can be found at Symfony and Doctorine code, as well as at Zend Framework. | ||
+ | |||
+ | ===== List of methods to implement ===== | ||
+ | |||
+ | * getAllAnnotations() | ||
+ | * getAnnotation(string annotationName) | ||
+ | * hasAnnotation(string annotationName) | ||
+ | |||
+ | The methods will be applied to: | ||
+ | * ReflectionClass | ||
+ | * ReflectionMethod | ||
+ | * ReflectionFunction | ||
+ | * ReflectionProperty | ||
+ | |||
+ | ===== Proposal and Patch ===== | ||
+ | |||
+ | The patch is not available yet. I don't mind to write it myself. | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * 2013-01-06 Initially created by Yahav Gindi Bar. | ||
rfc/reflection_doccomment_annotations.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1