Ticket #188 (closed enhancement: wontfix)

Opened 20 months ago

Last modified 19 months ago

Allow binding with annotations

Reported by: mikey Owned by: mikey
Priority: minor Milestone:
Component: InversionOfControl Version: SVN-trunk
Keywords: Cc:

Description

The injection container should allow to bind something based on an annotation. Example

class Foo
    /**
     * @Inject
     * @Dummy
     */
    public function setBar(Bar $bar) { ... }
    ...
}

$binder->bind('Bar')->to('DefaultBar');
$binder->bind('Bar')->annotatedWith('Dummy')->to('DummyBar');

This will inject DefaultBar instances to methods not annotated with @Dummy, and DummyBar instances to methods annotated with @Dummy. It is kind of similar to the @Named annotations, so I'm currently not seeing any real usecase for this, though. I just wanted to note the idea like seen in Google Guide, so it gets a low priority.

Change History

Changed 19 months ago by mikey

  • status changed from new to closed
  • resolution set to wontfix

We will not implement this, the @Named annotation should be sufficient for this. Using other annotations is only useful for type safety and to prevent typos, but is not worth the additional effort.

In other words: @Named is KISS.

Note: See TracTickets for help on using tickets.