Zend Framework

Mapping PHP to AS with annotations suggestion

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Zend_Amf
  • Labels:
    None

Description

The current implementation of mapping php classes to AS with either $_explicitType or getASClassName() seems pretty awkward to me. It adds members specific for amf to the classes which are meant to be most generic, VOs that is.
What I mean is that these classes can be heavily utilized by other services and inside php. So if every service It's meant for will require utilization of specific members, imagine what a mess it can make out of what is meant to be a simplest object.

What I suggest is to implement annotations parsing by means of Reflection. So that in the end it would look like:

/**
 * @ASClass{name=ContactVO}
 */
class Contact
{
    public $id;
    public $name;
    public $email;
}

Activity

Hide
Wade Arnold added a comment -

I really like this idea and something similar was part of the initial proposal. The issue that we had was that we really wanted to be able to cache the lookup the reflected lookup table for subsequent requests. We were worried about performance but is something that I hope we can add after the 1.8 release.

Show
Wade Arnold added a comment - I really like this idea and something similar was part of the initial proposal. The issue that we had was that we really wanted to be able to cache the lookup the reflected lookup table for subsequent requests. We were worried about performance but is something that I hope we can add after the 1.8 release.
Hide
Wade Arnold added a comment -

The current version in the incubator at least maps default class names with a one to one correspondence. I still really like using a doc comment and will try and get this in!

Show
Wade Arnold added a comment - The current version in the incubator at least maps default class names with a one to one correspondence. I still really like using a doc comment and will try and get this in!
Hide
Marijn Huizendveld added a comment -

Personally I think this would be the preferred way of declaring the mapping between ActionScript and PHP. I just started using Zend_Amf and I was actually surprised this isn't working already given the notice of method annotations being required.
I'm not familiar with the internals of Zend_Amf so I'm just spitballing here, perhaps a ClassMetaData class should be created that holds the cached class metadata...? A nice example of that can be seen in Doctrine 2

Show
Marijn Huizendveld added a comment - Personally I think this would be the preferred way of declaring the mapping between ActionScript and PHP. I just started using Zend_Amf and I was actually surprised this isn't working already given the notice of method annotations being required. I'm not familiar with the internals of Zend_Amf so I'm just spitballing here, perhaps a ClassMetaData class should be created that holds the cached class metadata...? A nice example of that can be seen in Doctrine 2

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated: