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();
}
}
大部分時間都取決於您的喜好, 我個人喜歡第二種方法 –