New core feature: Annotations

at 2005-02-28 in Announcements by friebe (0 comments)

As RFC #0016 is now implemented, we now have annotations.

Annotations?
The RFC says: Annotations (metadata) may be embedded within the sourcecode using the @ sign to prefix them.

Let's look at a small example:

  #[@webservice(name= 'Customer')]
class CustomerHandler extends Object {

#[@webmethod]
function getByCustomerId($customerId) {
// ...
}

#[@webmethod, @restricted(role= 'admin')]
function sendMessage($customerId, &$message) {
// ...
}
}

Now what else can we do with annotations?
Annotations are basically attributes to methods and come in useful where either the modifiers do not suffice (in webservices, not all public methods should be invokable, for instance) and when otherwise we would have used hardcoded method names or parts of names (the unit testing API selects all methods starting with the string "test" for invokation).

Play with your imagination. What pops to my mind:

  • Serialization / transformation of any sort
  • Deprecation
  • Dependencies
  • Aspect oriented programming

Maybe you have some more ideas?

Further reading



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES

Related

Find related articles by a search for «New».