<?php
require_once 'DocAnnotation.class.php';
class DBFieldType extends DocAnnotation {
public $type;
public $params = '';
}
class DBId extends DocAnnotation {
}
class DBTableName extends DocAnnotation {
public $name = '';
}
/**
* This describes a database table for persons.
* To seperate DocComments and annotations, nest
* the annotations in HTML comments like this:
* <!---
* @DBTableName("persons")
* -->
* note: the comment begins with
* <!--- instead of <!--
*/
class Person {
/**
* @DBFieldType(Varchar, 255)
* @DBId
*/
public $name;
/**
* @DBFieldType(Date)
* @DBId
*/
public $bdate;
/**
* @DBFieldType(Enum, {MEMBER, GUEST, OTHER})
*/
public $state;
}
echo "<pre>";
$p = new Person();
if (DocAnnotation::hasPropertyAnnotation($p, 'name', 'DBId'))
echo "the property Person->name represents a primary key.";
?>