6

我正在寻找可以定义当前 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;
4

1 回答 1

1

不幸的是,你不能——没有这样的标签(一般或特定于 PhpStorm)。

让我们希望他们(JetBrains 开发人员)对此有所作为:http: //youtrack.jetbrains.com/issue/WI-11022 -- vote/comment/etc,如果它会获得更多投票,我们可能会看到它很快实施(对现在“很快”已经很远了)。

于 2012-06-25T10:43:18.563 回答