PHP Classes
elePHPant
Icontem

Arroba: Extract annotation property values from classes

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2012-03-07 (4 years ago) RSS 2.0 feedNot enough user ratingsTotal: 324 All time: 6,805 This week: 1,068Up
Version License PHP version Categories
arroba 1GNU General Publi...5.3PHP 5, Language
Description Author

This class can extract annotation property values from classes.

It extends the reflection class to extract annotations from comments in the code of a given class.

The class can get the values of given properties defined specified class annotations.

Innovation Award
PHP Programming Innovation award nominee
December 2011
Number 6
Annotations consist of additional information that can be associated to different parts of the code of a project.

This class provides a solution to provide generic annotation support to PHP classes by extracting and parsing comments in the classes code with the annotation metadata in a format very similar to Java annotations.

Manuel Lemos
Picture of Evaldo Barbosa
  Performance   Level  
Name: Evaldo Barbosa <contact>
Classes: 3 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Details
Arroba : A simple and fast way to use annotations in php.

The need is the mother of invention, everybody knows this.
I needed to use annotations in php and a library that I found did not attend me in one aspect: I would have to extend that class
and thar would be very bad to me because it would extend my classes from my other classes (ORM, plugins...).
Arroba's syntax is simple to use because programming should be so. Creating or personalizing tags to use in your projects 
is now an easier job.
See above:

/**
 * Person
 * @author Evaldo Barbosa
 * @Table(table=tb_pessoa,pkey = id)
 */
class Person {
	/**
	 * Primary Key
	 * @type= integer
	 * @notnull = true
	 * @size=255
	 * @meta (conf1=mycond, conf2=your_c)
	 * @meta1 (attribute1=value_meta1)
	 */
	private $id;
	private $nome;
	protected $hash;
}

Class Person has annotations and one of its attributes has annotations too. 
You see two distinct types of annotations and A treats both.
See how to implement it with Arroba:

//To instantiate Arroba
$ref = new \Arroba\Arroba("Person");

//Getting a specific value of key of class annotation
	echo $ref->getClassAnnotation('@Model')->table;

//Getting a specific value of key of attribute annotation
	echo $ref->getPropertyAnnotation("id", "@meta1")->attribute1;
		
Why to get one annotation at a time?
Because you should know each annotation to treat each one individually.

  Files folder image Files  
File Role Description
Plain text file Arroba Class Arroba class
Accessible without login Plain text file README Doc. README

 Version Control Unique User Downloads Download Rankings  
 0%
Total:324
This week:0
All time:6,805
This week:1,068Up