I am struggling with custom objects autocomplete within 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.
For example:
$this->slider
contains array:
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? 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