DI: Smart @inject can look at use statements
- greeny
- Member | 405
Hi,
it would be nice, if @inject annotations in presenters, etc. will be smarter.
<?php
namespace Foo\Bar;
use Nette\Security;
use Nette\Security\User;
use Nette\Security\Identity as NIdentity;
class TesterClass {
/**
* @inject
* @var TesterClass
*/
public $testerClass;
/**
* @inject
* @var Security\IAuthenticator
*/
public $authenticator;
/**
* @inject
* @var User
*/
public $user;
/**
* @inject
* @var NIdentity
*/
public $identity;
?>
I tried to implement this, see pull . What do you think about it?
Last edited by greeny (23. 2. 2014 11:49)
- David Grudl
- founder | 8310
It is not possible because PHP has no API for checking use statements…
Yes, in Nette is AnnotationsParser::expandClassName(), but it
requires to parse whole PHP file, so it is very slow.
RSS feed
Topic closed