0
任何人都可以解释一下在Php-Di中的性能更好吗? 使用annotations
或plain constructor params
? 注解=少写字符,但这是一个很好的做法?Php-Di注释性能
class A {
/**
* @Inject
* @var B
**/
private $b;
use() {
$this->b->method();
}
}
Vs的:
class A {
/** @var B **/
private $b;
public function __constructor(B $b) {
$this->b=$b;
}
use() {
$this->b->method();
}
}
大部分时间都取决于您的喜好, 我个人喜欢第二种方法 –