PHPStorm - 包含的建议 HTML

PHPStorm - Suggestions in included HTML

如果我从 class Code_Controller.php 方法中包含 HTML 文件 Default.phtml,我无法在 Default.phtml 中看到变量 $data 的建议。 这是一个代码示例。

Code_Controller:

abstract class Core_Controller{
    protected $template;

    public function display(){
        $data['title']  = 'Title of site';

        if(Core_Config::$is_admin){
            require_once ADMIN_TEMPLATES_PATH . $this->template . '.phtml';
        }else{
            require_once PUBLIC_TEMPLATES_PATH . $this->template . '.phtml';
        }
    }
}

Default.phtml

<!DOCTYPE html>
<html>
<head>
    <title><?php echo $data['title'] ?></title>
</head>

<body>
    The content of the document......
</body>

</html>

有人知道吗?

感谢您的建议。

这种情况下的标准方法:使用 PHPDoc 并在那里(在文件顶部)声明该变量,例如

<?php
/** @var array $data */
?>
...HTML CODE HERE...