Method not found

dear all,

i am using an array to store several db connections inside, so at many lines i use this in my code:

$ret =  $this->db[$this->mode]['produkte']->sql_query("SELECT....");


of course phpstorm always says Method sql_query not found.

is there any way to let phpstorm know that this array $this->db is from class "db" ?
i know its working at other situations with special comments, but in this case i don´t know.

thanks for any help!

regards,
micha

2 comments

Hi there,

I do not think (although not 100% sure on this) that currently PhpStorm is able to provide type hints for two-dimensional arrays ( $var['first']['second'] ).  Single dimension ( $var['first'] ) -- easy.

If you can -- rewrite your code so only one or none at all dimensions is used, for example:

instead of $this->db[$this->mode]['bla-bla']
introduce function that takes 2 parameters, and you will use it this way: $this->getDB($this->mode, 'bla-bla');

Something like this:

/**

* Description ...

* @param ...
* @param ...

*

* @return Your_DB_CLass

*/

protected function getDB ($mode, $something) {
     return $this->db[$mode][$somehting];
}

or maybe even this way (if first parameter would be $this->mode all the time)

/**

* Description ...

* @param ...
*

* @return Your_DB_CLass

*/

protected function getDB ($something) {
     return $this->db[$this->mode][$somehting];
}

0

i will try, thank´s a lot for your advise ! ;)

0

Please sign in to leave a comment.