我正在寻找可以定义当前 php 模板的范围/上下文的文档注释。(类似于@var)
示例视图类:
<?php
class ExampleView {
protected $pageTitle;
public function __construct($title) {
$this->pageTitle = $title;
}
public function render() {
require_once 'template.php';
}
}
--
<?php
// template.php
/** @var $this ExampleView */
echo $this->pageTitle;
PHPStorm 给出检查错误,因为 $pageTitle 上的访问受到保护。
是否有提示给出范围?就像是:
<?php
// template.php
/** @scope ExampleView */ // <---????
/** @var $this ExampleView */
echo $this->pageTitle;