[TYPO3-mvc] idea: "magic" accessors via autoloader

Sebastian Fischer typo3 at fischer.im
Fri May 28 12:14:07 CEST 2010


On 28.05.2010 10:18, Martin Kutschker wrote:
> Hi!
>
> Now that we have an autoloader we can ship load any class we want to for the one that has been asked
> for. IIRC the AOP framework works that way. Instead of loading the real class it will return a
> generated proxy class.
>
> But why use a proxy if you can augment the real class? Changing a class on-the-fly is no big thing
> using PHP's tokenizer.
>
> So the idea is to create yet another annotation for properties that tells the autoloader to create
> default accessors if none are present in the source code.
>
> eg
>
> class Foo {
>
>    /**
>     * @accessors set get
>     */
>    protected $bar;
>
> }
>
> will be turned into this code:
>
> class Foo {
>
>    protected $bar;
>
>    public function setBar($value) {
>      $this->bar = $value;
>    }
>
>    public function getBar($value) {
>      return $this->bar;
>    }
>
> }
>
> No funny magic with __call and yet no tedious type work.
>
> But what does this mean for unit testing? Can it cope with the autoloader? Or does it need a special
> loader as well that does the generation magic just for the tests?
>
> Masi

 From the point of object oriented it would be nice to have that. From 
the point of performance, how does this behave? It smells like it could 
suffer from this magic class changing if no caching will be used for that.

Greetings
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list