How to tell PhpStorm class variable type
Hi,
Sometimes I wrap the built-in PHP classes with one of my own e.g.
class StatementWrapper{
private var $statement; //This will always be a mysqli_stmt object
function executeWrapped(){
//do some logging.
$this->statement->execute();
//do some other logging.
}
}
PhpStorm shows an error on the execute() line saying "Method 'execute' not found in class."
How do PhpStorm that the variable '$statement' will always be a mysqli_stmt object? Alternatively is there a way to make it not show that error for things that are only defined as vars?
cheers
Dan
btw Apologies if this is asked lots of times before - I couldn't find the answer easily.
请先登录再写评论。
might be this is the yet unresolved issue that your wanting:
http://youtrack.jetbrains.com/issue/WI-6027
its not supported yet as far as i know and whenever i run into chained methods while debugging with xdebug, things get real confusing real fast. Its scheduled for the next release though :)
Vote for it if it fits your situation.
Hi Danack,
Try adding PHPDoc block comment with type hint, like this:
Thanks - that works!