Documentation comments in yii2 say us that $this
pointer in layout files refer to yii\web\View
, but I'm confused that how this pointer can used outside of his class!?
If you debug the code deep enough, you will see this https://github.com/yiisoft/yii2/blob/master/framework/base/View.php#L341
They require a file in the method, that is why $this
point to class :)