简体   繁体   English

PhpStorm CodeIgniter自定义对象自动完成

[英]PhpStorm CodeIgniter custom objects autocomplete

I am struggling with custom objects autocomplete within Controllers/Views. 我正在为Controllers / Views中的自定义对象自动完成而苦苦挣扎。

Sample code 样例代码

$this->category      = $this->site_model->get_category($this->uri->uri_string());
    $this->languages     = $this->site_model->get_lang();
    $this->slider        = $this->site_model->get_slider();
    $this->static_texts  = $this->site_model->get_texts();
    $this->ads           = $this->site_model->get_ads();
    $this->currencies    = $this->site_model->get_currencies();
    $this->brands        = $this->site_model->get_brands(array('brand_visible'=>1));
    $this->goals         = $this->site_model->get_goal();
    $this->promo         = $this->site_model->get_promo();

These variables are running DB queries and generating arrays of objects. 这些变量正在运行数据库查询并生成对象数组。 I want to generate PHP doc so PhpStorm can provide autocomplete. 我想生成PHP文档,以便PhpStorm可以提供自动完成功能。

For example: 例如:

$this->slider contains array: $this->slider包含数组:

array(4) {
  [0]=>
  object(stdClass)#81 (3) {
    ["slide_id"]=>
    string(1) "1"
    ["slide_src"]=>
    string(13) "iamge.jpg"
    ["slide_href"]=>
    string(0) ""
  }
  [1]=>
  object(stdClass)#80 (3) {
    ["slide_id"]=>
    string(1) "2"
    ["slide_src"]=>
    string(10) "image2.jpg"
    ["slide_href"]=>
    string(0) ""
  }
  [2]=>
  object(stdClass)#79 (3) {
    ["slide_id"]=>
    string(1) "3"
    ["slide_src"]=>
    string(14) "image3.jpg"
    ["slide_href"]=>
    string(0) ""
  }
  [3]=>
  object(stdClass)#78 (3) {
    ["slide_id"]=>
    string(1) "4"
    ["slide_src"]=>
    string(13) "img.jpg"
    ["slide_href"]=>
    string(0) ""
  }
}

Should I declare PHPDoc in the controller? 我应该在控制器中声明PHPDoc吗? In the views? 在意见上? Please help. 请帮忙。

So far I made this in views so I don't get undefined variable. 到目前为止,我是在视图中创建的,这样就不会得到未定义的变量。 But I don't know what should I do with the arrays / objects. 但是我不知道该如何处理数组/对象。

<?php
/**
 * @see Site::index()
 * @var array $products
 */
?>

This is an example of some of mine for you 这是我的一个例子

/**
 * Create signing signature
 * @param   array   $params  Signature components
 * @param   string  $secret  Token secret (if required)
 * @param   string  $url     url for request method
 * @return  string           oAuth signature ready for use
 * @throws  Exception
 */
protected function makeSignature($url, $params, $secret = null)
{

this could also be helpful for you: https://www.phpdoc.org/docs/latest/references/phpdoc/basic-syntax.html 这也可能对您有所帮助: https : //www.phpdoc.org/docs/latest/references/phpdoc/basic-syntax.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM